multicall is a powerful tool to perform multiple actions in one transaction - instead of having to make multiple requests. However it can be a bit confusing to set up. Below are some examples:
balanceOf
(ERC-721) on multiple wallet addressesimport { encode, getContract, prepareContractCall, prepareTransaction, sendAndConfirmTransaction, } from "thirdweb"; // Init ERC-721 contract const contract = getContract({ chain: yourChain, address: "your-contract-address", }); const rawTxs = addresses.map((address) => prepareContractCall({ contract: contract, method: "function balanceOf(address owner) view returns (uint256)", params: [address], }) ); const encodedTxs = await Promise.all(rawTxs.map((tx) => encode(tx))); const multiCallTransaction = multicall({ contract, data: [encodedTxs] }); const data = await sendAndConfirmTransaction({ transaction: multiCallTransaction, account: yourAccount, });