我正在使用以下代码进行web3py合约交易:
txn = contract.functions.bid(
tokenId,
price
).buildTransaction({
'chainId': 56,
'gas': gasLimit,
'gasPrice': web3.toWei('5', 'gwei'),
'nonce': nonce
})
signed_txn = web3.eth.account.sign_transaction(txn, private_key=privateKey)
web3.eth.sendRawTransaction(web3.toHex(signed_txn.rawTransaction))然后,我在Bscscan上检查交易状态

Bscscan上的交易出现在05:54:42,但sendRawTransaction出现在05:54:39 (相差3秒)。有没有可能最小化这个时间差?
发布于 2021-11-18 18:27:52
如何处理交易速度?
为获得更快的速度,请调整您交易的汽油价格(交易费)。但是,请注意,越高GWEI =越高的速度=更高的速率。

如果您没有定义gasPrice事务对象,那么它将缺省为web3.eth.getGasPrice(),它通常是5gwei。
使用5 GWEI作为标准事务处理速度
.buildTransaction({
'chainId': 56,
'gas': gasLimit,
'nonce': nonce
})使用6 GWEI实现快速事务处理速度
.buildTransaction({
'chainId': 56,
'gasPrice': web3.toWei('6', 'gwei'),
'gas': gasLimit,
'nonce': nonce
})使用7 GWEI实现非常快的事务处理速度
.buildTransaction({
'chainId': 56,
'gasPrice': web3.toWei('7', 'gwei'),
'gas': gasLimit,
'nonce': nonce
})使用15Gwei或更多以实现即时事务处理速度
.buildTransaction({
'chainId': 56,
'gasPrice': web3.toWei('7', 'gwei'),
'gas': gasLimit,
'nonce': nonce
})通常情况下,7Gwei对大多数情况来说是绰绰有余的,可能是速度和燃气费成本之间的最佳成本效益。
但是,如果你真的需要保证即时事务,我推荐15Gwei或更高的gasPrice。
https://stackoverflow.com/questions/69485917
复制相似问题