Batch Transactions
Demo
Introduction
One great advantage of smart contract wallets is the ability to execute transactions in batches. That is, you can execute multiple transactions as if it's a single transaction, so you get to save on confirmation time and gas costs. It's also safer because these transactions either all execute or all revert, no in-between, which is a property known as "atomicity."
API
SDK
const txn = await ecdsaProvider.sendUserOperation([
{
target: "targetAddress1",
data: "callData1",
value: value1,
},
{
target: "targetAddress2",
data: "callData2",
value: value2,
},
])
Each object in the array for execBatch
can have three properties:
to
: the contract you are interacting withdata
: the calldatavalue
: the ETH value of the transaction (can be undefined)
Wagmi
import { usePrepareContractBatchWrite, useContractBatchWrite } from "@zerodev/wagmi";
Full Code (Editable)
Result
Loading...