sendCalls
Requests for the wallet to sign and broadcast a batch of calls (transactions) to the network.
Usage
import { parseEther } from 'viem'
import { account, walletClient } from './config'
 
const id = await walletClient.sendCalls({ 
  account,
  calls: [
    {
      to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
      value: parseEther('1')
    },
    {
      data: '0xdeadbeef',
      to: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
    },
  ],
})Notes:
- accountand- chainare top level properties as all calls should be sent by the same account and chain.
- Properties of callsitems are only those shared by all transaction types (e.g.data,to,value). The Wallet should handle other required properties like gas & fees.
- Read wallet_sendCallson EIP-5792.
Account Hoisting
If you do not wish to pass an account to every sendCalls, you can also hoist the Account on the Wallet Client (see config.ts).
import { walletClient } from './config'
 
const id = await walletClient.sendCalls({ 
  calls: [
    {
      to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
      value: parseEther('1')
    },
    {
      data: '0xdeadbeef',
      to: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
    },
  ],
})Returns
string
The identifier can be any arbitrary string. The only requirement is that for a given session, consumers should be able to call getCallsStatus with this identifier to retrieve a batch call status and call receipts.
Parameters
account
- Type: Account | Address
The Account to sign & broadcast the call from.
Accepts a JSON-RPC Account.
import { walletClient } from './config'
 
const id = await walletClient.sendCalls({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', 
  calls: [
    {
      to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
      value: parseEther('1')
    },
    {
      data: '0xdeadbeef',
      to: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
    },
  ],
})chain
- Type: Chain
- Default: walletClient.chain
The target chain to broadcast the calls.
import { mainnet } from 'viem/chains'
import { walletClient } from './config'
 
const id = await walletClient.sendCalls({
  chain: mainnet, 
  calls: [
    {
      to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
      value: parseEther('1')
    },
    {
      data: '0xdeadbeef',
      to: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
    },
  ],
})calls
- Type: Call[]
An array of calls to be signed and broadcasted.
import { mainnet } from 'viem/chains'
import { walletClient } from './config'
 
const id = await walletClient.sendCalls({
  chain: mainnet,
  calls: [ 
    { 
      to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', 
      value: parseEther('1') 
    }, 
    { 
      data: '0xdeadbeef', 
      to: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC', 
    }, 
  ], 
})calls.data
- Type: Hex
Calldata to broadcast (typically a contract function selector with encoded arguments, or contract deployment bytecode).
import { mainnet } from 'viem/chains'
import { walletClient } from './config'
 
const id = await walletClient.sendCalls({
  chain: mainnet,
  calls: [ 
    { 
      to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', 
      value: parseEther('1') 
    }, 
    { 
      data: '0xdeadbeef', 
      to: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
    },
  ],
})calls.to
- Type: Address
Recipient address of the call.
import { mainnet } from 'viem/chains'
import { walletClient } from './config'
 
const id = await walletClient.sendCalls({
  chain: mainnet,
  calls: [ 
    { 
      to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', 
      value: parseEther('1') 
    }, 
    { 
      data: '0xdeadbeef', 
      to: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC', 
    },
  ],
})calls.value
- Type: Address
Value to send with the call.
import { mainnet } from 'viem/chains'
import { walletClient } from './config'
 
const id = await walletClient.sendCalls({
  chain: mainnet,
  calls: [ 
    { 
      to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', 
      value: parseEther('1') 
    }, 
    { 
      data: '0xdeadbeef', 
      to: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
    },
  ],
})capabilities
- Type: WalletCapabilities
Capability metadata for the calls (e.g. specifying a paymaster).
import { walletClient } from './config'
 
const id = await walletClient.sendCalls({
  calls: [
    {
      to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
      value: parseEther('1')
    },
    {
      data: '0xdeadbeef',
      to: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
    },
  ],
  capabilities: { 
    paymasterService: { 
      url: 'https://...'
    } 
  } 
})
