| description | Submit multiple transactions concurrently using Tempo's expiring nonce system under-the-hood. |
|---|---|
| interactive | true |
import * as Demo from '../../../components/guides/Demo.tsx' import { AddFunds } from '../../../components/guides/steps/payments/AddFunds.tsx' import { Connect } from '../../../components/guides/steps/auth/Connect.tsx' import { SendParallelPayments } from '../../../components/guides/steps/payments/SendParallelPayments.tsx' import * as Token from '../../../components/guides/tokens' import { Cards, Card } from 'vocs'
Tempo enables concurrent transaction execution through its expiring nonce system. Unlike traditional sequential nonces that require transactions to be processed one at a time, expiring nonces allow multiple transactions to be submitted simultaneously without nonce conflicts. Each transaction uses an independent nonce that automatically expires after a set time window, enabling true parallel execution.
By the end of this guide you will understand how to send parallel payments using expiring nonces under-the-hood.
<Demo.Container name="Send Parallel Payments" footerVariant="balances" tokens={[Token.alphaUsd]}> </Demo.Container>
::::steps
Ensure that you have set up your project with Wagmi and integrated accounts by following either of the guides:
To send multiple transactions in parallel, simply batch them together. Expiring nonces are attached to each transaction automatically.
:::code-group
// @noErrors
import { Hooks } from 'wagmi/tempo'
import { parseUnits } from 'viem'
const alphaUsd = '0x20c0000000000000000000000000000000000001'
const { mutate: transfer } = Hooks.token.useTransferSync()
// Send both transfers in parallel. // [!code focus]
const [receipt1, receipt2] = await Promise.all([ // [!code focus]
transfer.mutate({ // [!code focus]
amount: parseUnits('100', 6), // [!code focus]
to: '0x70997970C51812dc3A010C7d01b50e0d17dc79C8', // [!code focus]
token: alphaUsd, // [!code focus]
}), // [!code focus]
transfer.mutate({ // [!code focus]
amount: parseUnits('50', 6), // [!code focus]
to: '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC', // [!code focus]
token: alphaUsd, // [!code focus]
}), // [!code focus]
]) // [!code focus]
console.log('Transaction 1:', receipt1.transactionHash) // [!code focus]
console.log('Transaction 2:', receipt2.transactionHash) // [!code focus]// @noErrors
// [!include ~/snippets/wagmi.config.ts:setup]:::
::::