Documentation for eth_defi.confirmation.wait_and_broadcast_multiple_nodes function.

wait_and_broadcast_multiple_nodes(web3, txs, confirmation_block_count=0, max_timeout=datetime.timedelta(seconds=300), poll_delay=datetime.timedelta(seconds=1), node_switch_timeout=datetime.timedelta(seconds=180), check_nonce_validity=True, mine_blocks=False)[source]

Try to broadcast transactions through multiple nodes.

  • Broadcast transaction through all nodes

  • Wait to confirm

  • If node_switch_timeout is reached, try to confirm using an alternative node

  • web3 (web3.main.Web3) – Web3 instance with eth_defi.provider.fallback.FallbackProvider configured as its RPC provider.

  • txs (Collection[Union[eth_account.datastructures.SignedTransaction, eth_defi.hotwallet.SignedTransactionWithNonce]]) –

    List of transaction to broadcast.

    Most be pre-ordered by (address, nonce).

  • confirmation_block_count (int) – How many blocks wait for the transaction receipt to settle. Set to zero to return as soon as we see the first transaction receipt.

  • node_switch_timeout

    Switch to alternative fallback node provider every time we reach this limit.

    Sometimes our node is malfunctioning (LlamaNodes, Ankr) and does not report transactions timely. Try with another node.

    See eth_defi.provider.fallback.FallbackProvider for details.

  • check_nonce_validity – Check if signed nonces match on-chain data before attempting to broadcat.

  • mine_blocks

    For forked mainnet RPCs (Anvil) make sure the blockchain is making blocks.

    Only use with Anvil.


Map of transaction hashes -> receipt

  • ConfirmationTimedOut – If we cannot get transactions out

  • NonceMismatch

    Starting nonce does not match what we see on chain.

    When check_nonce_validity is set.

  • Exception

    If all nodes fail to broadcast the transaction, then raise an exception.

    It’s likely that there is a problem with a transaction.

    The exception is raised after we try multiple nodes multiple times, based on node_switch_timeout and other arguments.

    A reverted transaction is not an exception, but will be returned in the receipts.

    In the case of multiple exceptions, the last one is raised. The exception is whatever lower stack is giving us.

  • OutOfGasFunds – The hot wallet account does not have enough native token to cover the tx fees.

Return type

Dict[hexbytes.main.HexBytes, dict]