An open API service indexing awesome lists of open source software.

https://github.com/patronum-labs/force-transfer

Singleton contract and a library containing smart contracts that allow for the force transfer of native tokens to addresses using selfdestruct
https://github.com/patronum-labs/force-transfer

eip-6780 force-send-value force-transfer msg-value selfdestruct

Last synced: about 1 year ago
JSON representation

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

Awesome Lists containing this project

README

          

# @patronumlabs/force-transfer

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/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](./SECURITY.md)**

## Installation

```bash
npm install @patronumlabs/force-transfer
```

## Usage

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

```solidity
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.

```javascript
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](https://github.com/Patronum-Labs/nick-method/tree/main)**, for more information please check **[DEPLOYMENT.md](DEPLOYMENT.md)**

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

## [`ForceTransfer`](./contracts/ForceTransfer.sol) Deployments

📌 The deployment address of [`ForceTransfer`](./contracts/ForceTransfer.sol) is **`0xBbfa4F54FF391957894c074A6eb34b7c967b7dAe`**.

> The Full list can be found in the [`deployments.json`](./deployments/deployments.json) file.

### EVM-Based Production Networks

- [LUKSO](https://explorer.execution.mainnet.lukso.network/address/0xBbfa4F54FF391957894c074A6eb34b7c967b7dAe)

### Additional EVM-Based Test Networks

- [LUKSO Testnet](https://explorer.execution.testnet.lukso.network/address/0xBbfa4F54FF391957894c074A6eb34b7c967b7dAe)

## Contributing

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

## License

[MIT License](LICENSE)