You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/building-on-etherlink/transactions.md
+95Lines changed: 95 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -363,6 +363,101 @@ async function sendTransaction() {
363
363
sendTransaction();
364
364
```
365
365
366
+
## Batching transactions
367
+
368
+
Because the sequencer orders transactions in the order that it receives them, you cannot expect transactions that you submit to run sequentially, even if you submit them quickly.
369
+
To ensure that your transactions run in the same block or sequence, you can submit them in a batch by signing them all first and submitting them at the same time.
370
+
371
+
The following example uses the [`viem`](https://viem.sh/) SDK to create five transactions that send XTZ to an account and submit them in a batch.
372
+
It configures the Viem client to send transactions as a batch, signs multiple transactions, and submits them all at once so Viem uses [Batch JSON-RPC](https://viem.sh/docs/clients/transports/http#batch-json-rpc) to send them as a batch.
373
+
374
+
Note that the code submits the transaction to the relay endpoint, not the usual RPC endpoint, because the public RPC node has a load balancer that splits transactions into single RPC requests.
375
+
However, the relay endpoint accepts transactions only via the `eth_sendRawTransaction` endpoint, so the code uses the `sendRawTransaction` method to send transactions to this endpoint.
376
+
Other EVM clients may not use this endpoint to send transactions and therefore cannot use the relay endpoint.
377
+
In this case, you can set up your own Etherlink EVM node and send batched transactions to it.
0 commit comments