Skip to content

Allows the contract owner to recover any ERC20 token sent into the contract for error

License

Notifications You must be signed in to change notification settings

troopcomm/eth-token-recover

 
 

Repository files navigation

ETH Token Recover

NPM Package CI Coverage Status MIT licensed

TokenRecover allows the contract owner to recover any ERC20 token sent into the contract for error.

Motivation

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.

Install

npm install eth-token-recover

Usage

pragma solidity ^0.8.0;

import "eth-token-recover/contracts/TokenRecover.sol";

contract MyContract is TokenRecover {
  // your stuff
}

Code

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.

Development

Install dependencies

npm install

Usage (using Hardhat)

Open the console

npm run console

Compile

npm run compile

Test

npm test

Code Coverage

npm run coverage

Linter

Check Solidity files

npm run lint:sol

Check JS/TS files

npm run lint:js

Fix JS and Solidity files

npm run lint:fix

License

Code released under the MIT License.

About

Allows the contract owner to recover any ERC20 token sent into the contract for error

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 80.1%
  • Solidity 19.9%