Solidity
合約遷移錯誤:無法儲存合約程式碼,請檢查您的gas量
我正在嘗試
ERC20
使用本地安裝的Truffle部署我的簡單令牌,但收到此錯誤: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
類包含: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); }
遷移 JS 文件:
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); };
環境:
Truffle v3.3.0, bundle version: 3.3.1 Solidity v0.4.11 (solc-js) EthereumJS TestRPC v3.0.5
所以我的令牌是從這個契約繼承的
ERC20
,但我什至無法編譯父級契約。怎麼了?
抽象合約不能被編譯(即使它們包含已實現的函式和未實現的函式),但它們可以用作基礎合約。
更多細節抽象合約