TokenRecover allows the contract owner to recover any ERC20 token sent into the contract for error.
There are lots of tokens lost forever into Smart Contracts (see OMG token balances). Each Ethereum contract is a potential token trap for ERC20 tokens. They can't be recovered so it means money losses for end users.
npm install eth-token-recover
pragma solidity ^0.8.0;
import "eth-token-recover/contracts/TokenRecover.sol";
contract MyContract is TokenRecover {
// your stuff
}
This repo contains:
Contract has a recoverERC20
function that transfers a tokenAmount
amount of tokenAddress
token to the contract owner.
function recoverERC20(address tokenAddress, uint256 tokenAmount) public virtual onlyOwner;
Note: only owner can call the recoverERC20
function so be careful when use on contracts generated from other contracts.
npm install
Use Solhint
npm run lint:sol
Use ESLint
npm run lint:js
Use Eslint and fix
npm run lint:fix
Open the Truffle console
npm run truffle:console
npm run truffle:compile
npm run truffle:test
Open the Hardhat console
npm run hardhat:console
npm run hardhat:compile
npm run hardhat:test
npm run hardhat:coverage
Code released under the MIT License.