-
Could not transact with/call contract function, is contract deployed correctly and chain synced
智能合約的函數(shù)調(diào)用有如下兩種方式:
# 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不改變合約狀態(tài)统台,read only变骡;transact可能會改變合約狀態(tài)术健,R&W
-
gas required exceeds allowance or always failing transaction
沒有設(shè)定transaction的gasLimit虑凛,如下設(shè)定
myContract.functions.name().call({"gasLimit":100000})
-
gas required exceeds block gasLimit
這個問題就很詭異,因?yàn)楣?jié)點(diǎn)的blockNumber始終為0奕污,導(dǎo)致block的gasLimit一直為創(chuàng)世節(jié)點(diǎn)的5000。
最終通過修改指令,加上 --syncmode light 讓節(jié)點(diǎn)可以接受够掠、廣播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
-
備注
- web3py地址: https://web3py.readthedocs.io/en/stable/quickstart.html
- blockNumber始終為0的討論:https://github.com/ethereum/go-ethereum/issues/16147