useSendCalls

A hook to send EIP-5792 calls to a wallet. This hook works with all Thirdweb wallets (in-app and smart) and certain injected wallets that already support EIP-5792. Transactions will be bundled and sponsored when those capabilities are supported, otherwise they will be sent as individual transactions.

When calls are sent, all contracts that are interacted with will have their corresponding reads revalidated via React Query.

Example

import { useSendCalls } from "thirdweb/react";
const sendTx1 = approve({
contract: USDT_CONTRACT,
amount: 100,
spender: "0x33d9B8BEfE81027E2C859EDc84F5636cbb202Ed6",
});
const sendTx2 = approve({
contract: USDT_CONTRACT,
amount: 100,
spender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
});
const { mutate: sendCalls, data: bundleId } = useSendCalls({
client,
});
await sendCalls({
wallet,
client,
calls: [sendTx1, sendTx2],
});

Await the bundle's full confirmation:

const { mutate: sendCalls, data: bundleId } = useSendCalls({
client,
waitForResult: true,
});
await sendCalls({
wallet,
client,
calls: [sendTx1, sendTx2],
});

Sponsor transactions with a paymaster:

const { mutate: sendCalls, data: bundleId } = useSendCalls();
await sendCalls({
client,
calls: [sendTx1, sendTx2],
capabilities: {
paymasterService: {
url: `https://${CHAIN.id}.bundler.thirdweb.com/${client.clientId}`
}
}
});
@note We recommend proxying any paymaster calls via an API route you setup and control.

Parameters

Returns

A React Query mutatuon object to interact with sendCalls