简体   繁体   English

web3.eth.sendRawTransaction 和 Bscscan 上交易验证时间之间的时间

[英]Time between web3.eth.sendRawTransaction and transaction validated time on Bscscan

I'm making web3py contract transaction, using this code:我正在使用以下代码进行 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))

Then, I check transaction status on Bscscan然后,我在 Bscscan 上检查交易状态在此处输入图片说明

The transaction appeared on Bscscan at 05:54:42, but sendRawTransaction was at 05:54:39 (3 secs difference).该交易于 05:54:42 出现在 Bscscan 上,但 sendRawTransaction 出现在 05:54:39(3 秒差异)。 Is it possible to minimize this time difference?是否有可能最小化这个时差?

HOW TO HANDLE TRANSACTION SPEED?如何处理交易速度?

For greater speed adjust the gas price (transaction fee) for your transaction.为了更快地调整您的交易的天然气价格(交易费)。 However, be aware that Higher GWEI = Higher Speed = Higher Rates.但是,请注意,更高的 GWEI = 更高的速度 = 更高的费率。

在此处输入图片说明

If you don't define the gasPrice transaction object it will default to web3.eth.getGasPrice() which is often 5 gwei.如果您没有定义 gasPrice 交易对象,它将默认为web3.eth.getGasPrice() ,通常为 5 gwei。 [READ MORE] [阅读更多]

USE 5 GWEI FOR STANDARD TRANSACTION SPEED使用 5 GWEI 达到标准交易速度

.buildTransaction({
'chainId': 56,
'gas': gasLimit,
'nonce': nonce
})

USE 6 GWEI FOR FAST TRANSACTION SPEED使用 6 GWEI 加快交易速度

.buildTransaction({
'chainId': 56,
'gasPrice': web3.toWei('6', 'gwei'),
'gas': gasLimit,
'nonce': nonce
})

USE 7 GWEI FOR VERY FAST TRANSACTION SPEED使用 7 GWEI 以实现非常快的交易速度

.buildTransaction({
'chainId': 56,
'gasPrice': web3.toWei('7', 'gwei'),
'gas': gasLimit,
'nonce': nonce
})

USE 15 GWEI OR MORE FOR INSTANT TRANSACTION SPEED使用 15 GWEI 或更多以获得即时交易速度

.buildTransaction({
'chainId': 56,
'gasPrice': web3.toWei('7', 'gwei'),
'gas': gasLimit,
'nonce': nonce
})

Typically 7 GWEI is more than enough for most cases, being perhaps the best cost-benefit between speed and cost in gas fees.对于大多数情况,通常 7 GWEI 绰绰有余,这可能是速度和 gas 费用成本之间的最佳成本效益。

However if you really need to guarantee instant transactions I recommend gasPrice of 15 GWEI or above.但是,如果您确实需要保证即时交易,我建议 gasPrice 为 15 GWEI 或更高。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM