# ETH Token Recover

NPM Package (opens new window) CI (opens new window) Coverage Status (opens new window) MIT licensed (opens new window)

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 (opens new window) 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

# Linter

Use Solhint

npm run lint:sol

Use ESLint

npm run lint:js

Use Eslint and fix

npm run lint:fix

# Usage (using Truffle)

Open the Truffle console

npm run truffle:console

# Compile

npm run truffle:compile

# Test

npm run truffle:test

# Usage (using Hardhat)

Open the Hardhat console

npm run hardhat:console

# Compile

npm run hardhat:compile

# Test

npm run hardhat:test

# Code Coverage

npm run hardhat:coverage

# License

Code released under the MIT License (opens new window).