Wallet Call API (EIP-5792) support in the Connect SDK

Greg

EIP-5792 simplifies how apps can leverage wallets' full capabilities like batch transactions, sponsored transactions, auxiliary funds, and anything else smart contract accounts are now capable of. We've added built-in support for wallet_sendCalls, wallet_getCapabilities, and wallet_getCallsStatus so app developers can provide the best possible user experience regardless of the wallets their users bring to the app. With v5.22.0 the Connect SDK exposes 3 simple functions to take advantage of the Wallet Call API.

0:00
/3:01

Send multiple transactions at once with any wallet

Send any number of transactions via the sendCalls function. You prepare the transactions as if you were using sendTransactions, then pass them as an array to sendCalls.

import { createThirdwebClient } from "thirdweb";
import { mainnet } from "thirdweb/chains";
import { sendCalls } from "thirdweb/wallets/eip5792";
const client = createThirdwebClient({ clientId: ... });
const USDC_CONTRACT = getContract({
client,
chain: mainnet,
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
})
const send1 = transfer({
contract: USDC_CONTRACT,
amount: 100,
to: "0x33d9B8BEfE81027E2C859EDc84F5636cbb202Ed6",
});
const send2 = transfer({
contract: USDC_CONTRACT,
amount: 100,
to: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709"
});
const bundleId = await sendCalls({
wallet, // get your wallet using createWallet or useActiveWallet
client,
calls: [send1, send2],
});

We try to make sendCalls as compatible as possible with all wallets, so you don't need to worry about what type of wallet the user has connected. It currently works with Coinbase Smart Wallet, thirdweb in-app wallets, thirdweb smart wallets, and any third party wallets that currently support EIP-5792. In future releases, we'll add fallback support so the wallet reverts to traditional transactions if it doesn't support EIP-5792. Until then, we recommend wrapping sendCalls in a try block to catch any errors from unsupported wallets.

Sponsoring transactions

Sponsor your user's transactions with a single line by adding the thirdweb paymaster URL:

const bundleId = await sendCalls({
wallet, // get your wallet using createWallet or useActiveWallet
client,
calls: [send1, send2],
capabilities: {
paymasterService: {
url: `https://${CHAIN.id}.bundler.thirdweb.com/${client.clientId}`,
},
},
});

You'll be able to configure which domains use this paymaster URL in your thirdweb dashboard. For more complicated paymaster logic, you can setup a paymaster proxy based on ERC-7677.

Get the status of a call bundle

Once you send a set of calls to your wallet, fetch their status using getCallsStatus. This will return a status field of either "CONFIRMED" or "PENDING" and a receipts array containing the completed transaction receipts.

import { createThirdwebClient } from "thirdweb";
import { sendCalls, getCallsStatus } from "thirdweb/wallets/eip5792";
const client = createThirdwebClient({ clientId: ... });
const bundleId = await sendCalls({ wallet, client, calls });
let result;
while (result.status !== "CONFIRMED") {
result = await getCallsStatus({ wallet, client, bundleId });
}

Get a wallet's smart account capabilities

Knowing what UX a wallet can provide helps you surface the right features to your app's users. getCapabilities returns an object showing the capabilities for different chains the wallet has access to. For thirdweb in-app wallets, this will be the currently connected chain.

import { createWallet } from "thirdweb/wallets";
import { getCapabilities } from "thirdweb/wallets/eip5792";
const wallet = createWallet("com.coinbase.wallet");
const capabilities = await getCapabilities({ wallet });

Over the coming weeks we'll release additional improvements / support for EIP-5792 and other standards for making dApp development easier than ever.