truffle相关ERROR解决记录

truffle各类报错解决:Error encountered, bailing;Error: VM Exception while processing transaction: revert;TypeError: Cannot read property ‘apply’ of undefined;UnhandledPromiseRejectionWarning;DeprecationWarning;UnhandledPromiseRejectionWarning;out of gas

更多区块链技术与应用分类:

区块链应用    区块链开发

以太坊 | Fabric | BCOS | 密码技术 | 共识算法 | 比特币其他链

通证经济传统金融场景 | 去中心化金融 | 防伪溯源 | 数据共享 | 可信存证

1.truffle migrate时报错

错误描述

Error encountered, bailing. Network state unknown. Review successful transactions manually.

Error: VM Exception while processing transaction: revert

解决方法

“revert”一般是require语句导致,部署合约时,运行constructor函数,故可能是构造函数中有bug :

constructor (){

// 其中有bug;

}

通过逐步注释,得出,注释掉该句

constructor () public payable {
       require(HOUSE_POOL_WIN_PRIZE_PERCENT + HOUSE_POOL_BONUS_PERCENT + HOUSE_POOL_NEXT_ROUND_PERCENT + HOUSE_POOl_ADMIN_PERCENT == 1 ether);
       house = msg.sender;
       playState = PlayState.Created;
       OAR = OraclizeAddrResolverI(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475);
       --> oraclize_setProof(proofType_TLSNotary | proofStorage_IPFS); // 该句出错
       lottery3DNumber = Lottery3DNumber(msg.sender);
   }

2.truffle-contract 1.0.0报错

错误描述

TypeError: Cannot read property 'apply' of undefined

解决方法

每个deployed合约执行:

   if (typeof func.currentProvider.sendAsync !== "function") {
       func.currentProvider.sendAsync = function () {
           return func.currentProvider.send.apply(
               func.currentProvider, arguments
           );
       };
   }

3.调用合约方法时报错:

错误描述

(node:8724) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: First argument must be a string or Buffer

(node:8724) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

解决方法

res.end(issue) //issue为promise不能直接使用 改为: res.end(JSON.stringify(issue))

4. 调用合约中mapping结构数据时出错

错误描述

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Invalid number of arguments to Solidity function

解决方法

必须给参数:

return lotteryGameEngineInst.allBet(0); // 给参数

5.部署合约时报错

错误描述

out of gas

解决方法

在truffle里添加gas费

networks: {
   development: {
       host: "127.0.0.1",
       port: 7545,
       network_id: "*",
       gas: 8000000,
   }
},


原文链接:truffle相关ERROR解决记录 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值