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.
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
npm install @patronumlabs/force-transfer
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();
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.
Contributions are welcome! Please feel free to submit a Pull Request.