【问题标题】:Time between web3.eth.sendRawTransaction and transaction validated time on BscscanBscscan 上 web3.eth.sendRawTransaction 和事务验证时间之间的时间
【发布时间】:2021-11-27 19:49:45
【问题描述】:

我正在使用以下代码进行 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 上检查交易状态

交易在 05:54:42 出现在 Bscscan 上,但 sendRawTransaction 出现在 05:54:39(相差 3 秒)。有没有可能把这个时间差减到最小?

【问题讨论】:

    标签: python blockchain web3 web3py bscscan


    【解决方案1】:

    如何处理交易速度?

    为了更快地调整您的交易的汽油价格(交易费用)。但是,请注意更高的 GWEI = 更高的速度 = 更高的速率。

    如果您没有定义 gasPrice 交易对象,它将默认为 web3.eth.getGasPrice(),通常为 5 gwei。 [READ MORE]

    使用 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
    })
    

    使用 15 GWEI 或更高的即时交易速度

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

    对于大多数情况,通常 7 GWEI 绰绰有余,这可能是速度和 gas 费用成本之间的最佳成本效益。

    但如果你真的需要保证即时交易,我建议 gasPrice 为 15 GWEI 或以上。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-14
      • 2015-02-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多