[英]Web3-Py : Nonce Transaction Overwriting Problem
你好,我正在使用 python web3 发送交易,但 nonce 是我的代码的问题
w3 = Web3(Web3.HTTPProvider("https://rpc.tomochain.com/"))
mainWallet = '0xAad6a88877E6AB7FbC33fdAce672780A85Fc88a8'
nonce = w3.eth.getTransactionCount(mainWallet)
amount_to_send = 0.01
private_key = 'xxxxxxxx'
tx = {
'nonce': nonce,
'to': to_address,
'value': w3.toWei(amount_to_send, 'ether'),
'gas': 21000,
'gasPrice': w3.toWei('0.3', 'gwei')
}
sign_tx = w3.eth.account.signTransaction(tx, private_key)
tran_hash = w3.eth.sendRawTransaction(sign_tx.rawTransaction)
txn = w3.toHex(tran_hash)
print(txn)
上面的代码很好地处理了交易,但问题是当超过 1 个用户试图提取 nonce 问题时,假设用户 1 请求提取 0.001 和用户 2 请求提取 0.002,并且他们同时请求然后 0.001 交易被取消只有 0.002 通过
我该怎么做才能让他们都通过
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.