5

I am trying to deploy my simple ERC20 token with locally installed Truffle, but received this error:

truffle migrate --reset
Using network 'development'.

Running migration: 1_initial_migration.js
  Replacing Migrations...
  Migrations: 0xc67440ccf402de259e5d6193eec29283bcb5555e
Saving successful migration to network...
Saving artifacts...
Running migration: 2_deploy_contracts.js
  Deploying ERC20...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: The contract code couldn't be stored, please check your gas amount.

ERC20 class contains:

pragma solidity ^0.4.11;

    contract ERC20 {
        //uint public totalSupply;
        function totalSupply() constant returns (uint totalSupply);

        function balanceOf(address _owner) constant returns (uint balance);
        function transfer(address _to, uint _value) returns (bool success);
        function transferFrom(address _from, address _to, uint _value) returns (bool success);
        function approve(address _spender, uint _value) returns (bool success);
        function allowance(address _owner, address _spender) constant returns (uint remaining);

        event Transfer(address indexed _from, address indexed _to, uint _value);
        event Approval(address indexed _owner, address indexed _spender, uint _value);
    }

Migration JS file:

var ERC20 = artifacts.require("./ERC20.sol");
var SafeMath = artifacts.require("./SafeMath.sol");

var MyToken = artifacts.require("./MyToken.sol");

module.exports = function(deployer) {
  deployer.deploy(ERC20);
  //deployer.deploy(SafeMath);
  //deployer.link(ERC20, MyToken);
  //deployer.link(SafeMath, MyToken);

  //deployer.deploy(MyToken);
};

Environment:

Truffle v3.3.0, bundle version: 3.3.1
Solidity v0.4.11 (solc-js)
EthereumJS TestRPC v3.0.5

So my token is inherited from this ERC20 contract, but I even can't compile parent one contract. What is wrong?

  • can you also share your 2_deploy_contracts.js file. – Sanchit Jun 30 '17 at 13:42
  • @Sanchit yes, added. – Dmytro Zarezenko Jun 30 '17 at 14:31
  • Normally when you have too many files to deploy in migration file, then breaking them into multiple can fix the out of gas issue, but here in your case, that doesn't seem to be an issue. – Sanchit Jun 30 '17 at 22:04
  • So, what can it be then? – Dmytro Zarezenko Jul 1 '17 at 6:52
  • 4
    Your ERC20.sol is an abstract contract solidity.readthedocs.io/en/develop/…: Such contracts cannot be compiled, it will fail to deploy. – Ismael Jul 2 '17 at 4:17
2

Abstract contract cannot be compiled (even if they contain implemented functions alongside non-implemented functions), but they can be used as base contracts.

More details Abstract Contracts

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.