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?
had the same, this helped:
rm -R build/
not sure why.
It looks like you're deploying an abstract contract (you have functions that aren't fully defined). You can't deploy abstract contracts to the Ethereum blockchain. If you run into any more issues please open a new issue.
I had the same problem. I want to give extra information for other people facing the same problem:
I had something like that:
contract Interface{
function foo(uint256 param1, address param2) returns (uint);
}
contract myContract is Interface{
function foo(uint24 param1, address param2) returns (uint) { return 0}
}
Since param1 on the Interface contract is uint256 and, by the other hand, uint24 on myContract, it will fail as Interface is not fully implemented and I'm trying to deploy myContract (which is inherited from Interface).
But.. You can deploy the following:
contract ERC20{
function foo(uint256 param1, address param2) returns (uint);
}
contract myContract {
function mint() {
ERC20 token = ERC20(<address>);
.............
}
}
Because you are not trying to deploy ERC20. It will be embeeded on MyContract which have to be fully implemented.
Anyways, the error message is not descriptive.
I had the same problem. I solved it like following in my case.
// before
if (proof != hoge) throw;
// after
if (proof != hoge) {
throw;
}
Have same error In My case It was a bad constructor
contract StupidMistakeMock is StupidMistake{
function StupidMistakeMock(address ico,address benef,uint32 _divPeriod)
StupidMistakeMock(ico,benef,_divPeriod) {
while it should be
contract StupidMistakeMock is StupidMistake{
function StupidMistakeMock(address ico,address benef,uint32 _divPeriod)
StupidMistake(ico,benef,_divPeriod) {
I had an interface that said a function was external, but the contract had it as public. Easy fix, when you know what it is, took me a while to figure it out
When I was deploying TCR contracts (https://github.com/skmgoldin/tcr) I also was given this error.
To silence the ~violence~ error I simply commented out the gas settings in the truffle.js config file.
rinkeby: {
provider: () => new HDWalletProvider(mnemonic, 'https://rinkeby.infura.io'),
network_id: '*',
// gas: 4500000,
// gasPrice: 25000000000,
},
I got this error by not specifying all inheritances
contract C{
}
contract B is C{
}
//Now this gave me the error:
contract A is B{
}
But this worked:
contract A is B,C {
}
Most helpful comment
It looks like you're deploying an abstract contract (you have functions that aren't fully defined). You can't deploy abstract contracts to the Ethereum blockchain. If you run into any more issues please open a new issue.