Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ethereum 为什么我的Solidity以太坊合同耗尽了汽油?_Ethereum_Solidity_Truffle_Ganache - Fatal编程技术网

Ethereum 为什么我的Solidity以太坊合同耗尽了汽油?

Ethereum 为什么我的Solidity以太坊合同耗尽了汽油?,ethereum,solidity,truffle,ganache,Ethereum,Solidity,Truffle,Ganache,块菌迁移-重置 编辑您的合同。。。 一切都是最新的,没有什么可编译的 正在开始迁移。。。 网络名称:“开发” 网络id:5777 区块气限值:672197500(0x2810eb7c) 1_initial_migration.js 替换“迁移” 事务哈希:0xf41feee2b768ba375d95ded5c40a48e7af3d59554f616738102a2a9805824d77 区块:0秒:0 合同地址:0xe75Ea4aDD9728c9846778a695cE0CF32b66C1c52

块菌迁移-重置

编辑您的合同。。。 一切都是最新的,没有什么可编译的

正在开始迁移。。。 网络名称:“开发” 网络id:5777 区块气限值:672197500(0x2810eb7c)

1_initial_migration.js 替换“迁移” 事务哈希:0xf41feee2b768ba375d95ded5c40a48e7af3d59554f616738102a2a9805824d77 区块:0秒:0 合同地址:0xe75Ea4aDD9728c9846778a695cE0CF32b66C1c52 街区编号:1 块时间戳:1621246185 账户:0x33B005E2F8D83120B4AB4BD1BD7AD704077801 结余:99.99626098 所用气体:186951(0x2da47) 天然气价格:20 gwei 发送值:0以太 总成本:0.00373902以太

将迁移保存到链。 保存工件


总成本:0.00373902以太

2_deploy_contracts.js 取代“加密男孩” 错误:**部署失败***

“CryptoBoys”耗尽了汽油(使用您在网络配置或部署参数中设置的值)

  • 块限制:672197500(0x2810eb7c)
  • 发送气体:6721975(0x6691b7)
当我编写这个函数时,它导致了上述错误

    function getAllTokensMintedByUser(address user) public view returns(CryptoBoy[] memory result){
        
        uint256 k=0;
        result=new CryptoBoy[](totalMintedTokens[user]);
        if(totalMintedTokens[user]!=0){
            for(uint256 i=1; i<=cryptoBoyCounter; i++) {
            
            CryptoBoy memory cryptoboy=allCryptoBoys[i];
            if(cryptoboy.mintedBy==user){
              result[k]=cryptoboy;
              k++;
            }
          }
        }
        
        return result;
      }
函数getAllTokensMintedByUser(地址用户)公共视图返回(CryptoBoy[]内存结果){
uint256k=0;
结果=新加密男孩[](totalMintedTokens[用户]);
如果(totalMintedTokens[用户]!=0){

对于(uint256 i=1;i,您的合同可能超过24KB的代码限制

但是,您可以尝试在
truffle config.js
中手动设置用于部署到
开发
网络的气体限制:

development : {
 ...
 gas: 6000000
}

有一个代码大小限制。它应该小于24Kb。使用此工具检查合同大小