[英]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.