Skip to content

Singleton contract and a library containing smart contracts that allow for the force transfer of native tokens to addresses using selfdestruct

License

Notifications You must be signed in to change notification settings

Patronum-Labs/force-transfer

Repository files navigation

@patronumlabs/force-transfer

License: MIT

This package provides a library contract that helps to force transfer native tokens to contracts that cannot receive value, that do not have the receive function. The package includes the constants related to the ForceTransfer Singleton.

Rationale

The Force transfer contract is a singleton that allows to force the transfer of a native token to addresses without relying on solidity's call feature and uses self-destruct to force send the value.

ForceTransferLib is a contract to be used by other developers in development to integrate the logic of force sending within their contracts and protocols.

Use at your own risk and please check SECURITY.md

Installation

npm install @patronumlabs/force-transfer

Usage

Here's an example of how to use the ForceTransferLib in your Solidity contract:

pragma solidity ^0.8.0;

import "@patronumlabs/force-transfer/contracts/ForceTransferLib.sol";

contract MyContract {
  function forceTransferToAddress(address payable recipient) external payable {
    ForceTransferLib.force(recipient, msg.value);
  }
}

Constants related to the ForceTransfer Singleton are exported as well.

import { FORCE_TRANSFER_SINGLETON_CONFIG } from "@patronumlabs/force-transfer/constants.js";

function checkRawTransactionAndDeployer() {
  console.log(FORCE_TRANSFER_SINGLETON_CONFIG.rawTx);
  console.log(FORCE_TRANSFER_SINGLETON_CONFIG.deployerAddress);
}

checkRawTransactionAndDeployer();

Deployment

For deployment of the ForceTransfer Singleton, the nick-method is used with a pre-signed rawTx generated by @patronumlabs/nick-method, for more information please check DEPLOYMENT.md

If you need help deploying on a specified network, feel free to submit an issue.

ForceTransfer Deployments

📌 The deployment address of ForceTransfer is 0xBbfa4F54FF391957894c074A6eb34b7c967b7dAe.

The Full list can be found in the deployments.json file.

EVM-Based Production Networks

Additional EVM-Based Test Networks

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License