1
contract_txn = weth_contract.functions.redeem(address, True).buildTransaction({
                                'type': '0x2',
                                'chainId': 43114,                            
                                'gas': 8000000,
                                'maxFeePerGas': 2 * block['baseFeePerGas'],  # required for dynamic fee transactions
                                'maxPriorityFeePerGas': 0,  # required for dynamic fee transactions
                                'nonce': nonce,
    })


signed = w3.eth.account.sign_transaction(contract_txn, privatekey)
tx_hash =w3.eth.send_raw_transaction(signed.rawTransaction)
    })

Above is the transaction sign formatting I have been using. I have been doing this on the Avalanche network and it used to work instantly.

But when I tried it again recently, it would take anywhere from 10 mins to forever to get broadcast on the chain.

If I keep attempting to broadcast the same transaction with the same nonce, I eventually end up with the following error.

    tx_hash =w3.eth.send_raw_transaction(signed.rawTransaction)
  File "/home/blackwidow/.local/lib/python3.8/site-packages/web3/eth.py", line 698, in send_raw_transaction
    return self._send_raw_transaction(transaction)
  File "/home/blackwidow/.local/lib/python3.8/site-packages/web3/module.py", line 57, in caller
    result = w3.manager.request_blocking(method_str,
  File "/home/blackwidow/.local/lib/python3.8/site-packages/web3/manager.py", line 187, in request_blocking
    return self.formatted_response(response,
  File "/home/blackwidow/.local/lib/python3.8/site-packages/web3/manager.py", line 168, in formatted_response
    raise ValueError(response["error"])
ValueError: {'code': -32000, 'message': 'already known'}

I have forked the network and tried it locally using the same format. The tx was broadcast and the change was made to my wallet balance instantly when it was local.

2
  • Resend the transaction with increased gasPrice to replace the current one.
    – rlib
    Dec 26, 2021 at 19:32
  • @rlib would that work for a PoS chain like Avalanche?
    – Blackwidow
    Dec 26, 2021 at 19:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.