美文网首页以太坊
web3.py开发之坑

web3.py开发之坑

作者: 空即是色即是色即是空 | 来源:发表于2018-09-23 23:11 被阅读563次
    • Could not transact with/call contract function, is contract deployed correctly and chain synced
      智能合约的函数调用有如下两种方式:
    # Execute smart contract function in the EVM without sending any transaction
    myContract.functions.myFunction([param1]).call(options[])
    
    # Will send a transaction to the smart contract and execute its function
    myContract.functions.myFunction([param1]).transact(options[])
    

    call不改变合约状态,read only;transact可能会改变合约状态,R&W

    • gas required exceeds allowance or always failing transaction
      没有设定transaction的gasLimit,如下设定
    myContract.functions.name().call({"gasLimit":100000})
    
    • gas required exceeds block gasLimit
      这个问题就很诡异,因为节点的blockNumber始终为0,导致block的gasLimit一直为创世节点的5000。
      最终通过修改指令,加上 --syncmode light 让节点可以接受、广播transaction,最终解决问题
    geth --datadir data --syncmode fast --rpcapi eth,web3,personal --rpc --cache=2048  console 2>>test.log
    > eth.blockNumber
    > 0
    > eth.getBlock("latest")
    > ...
    
    • 其它问题
      • transfer之前需要unlock account

    相关文章

      网友评论

        本文标题:web3.py开发之坑

        本文链接:https://www.haomeiwen.com/subject/hfaqoftx.html