@patronumlabs/force-transfer

2.1.0 • Public • Published

@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.

Contributing

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

License

MIT License

Package Sidebar

Install

npm i @patronumlabs/force-transfer

Weekly Downloads

0

Version

2.1.0

License

MIT

Unpacked Size

11 kB

Total Files

7

Last publish

Collaborators

  • yamenmerhi