I have two contract

1) ERC20 contract

2) ERC20 token registry contract which is invoking my token contract and making a transfer function call to the token

But function call is ending up with an error stating that the transaction to ERC20Registry.deployERC20 failed:

VM error: revert. revert The transaction has been reverted to the initial state. Note: The constructor should be payable if you send value. Debug the transaction to get more information.


Token Registry Contract

pragma solidity >=0.4.24;

import './TERC20.sol';

contract ERC20Registry {
  function deployERC20(
    string _Name,
    string _Symbol,
    uint256 _initialSupply
    returns (address)
      TERC20 token = new TERC20(_Name, _Symbol, 18, _initialSupply);
     token.transfer(tx.origin, token.totalSupply());
     return address(token);

Token Contract

pragma solidity >=0.4.24;

import "./ERC20.sol";
import "./ERC20Detailed.sol";
import "./Ownable.sol";

contract TERC20 is ERC20, ERC20Detailed, Ownable {
  constructor (
    string memory name,
    string memory symbol,
    uint8 decimals,
    uint256 initialSupply
  ERC20Detailed(name, symbol, decimals) 
    emit Transfer(0x0, tx.origin, initialSupply);
  • 2
    Difficult to say. I suggest you simply comment out some require statements from the token contract until you find out which causes it. Most likely it's some check in the transfer function. – Lauri Peltonen Apr 20 at 14:34
  • Thanks for the Edit Rob, Let me check further on what you have suggested @Lauri.. But as i said transfer of ERC20 should not require function to make payable – Devraj Singh Rawat Apr 22 at 4:36
  • The part about payable is just a guess from the compiler and typically it's incorrect, so you can just ignore that. – Lauri Peltonen Apr 22 at 6:07
  • @DevrajSinghRawat What does ERC20 and ERC20Detailed look like? How do you call deployERC20? Also the Transfer event seem incorrect in TERC20. – Ismael Apr 22 at 6:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.