Skip to content

ServerActions.sendCalls

Viem Action for broadcasting a call bundle to the RPC Server. This is a convenience function that prepares, signs, and sends calls in one operation.

Usage

example.ts
import { ServerActions, Key } from 'porto/viem'
import { parseEther } from 'viem'
import { client, account } from './config'
 
const key = Key.createSecp256k1()
 
const result = await ServerActions.sendCalls(client, { 
  account, 
  calls: [{ 
    to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', 
    value: parseEther('0.01'), 
  }], 
  key, 
}) 

Parameters

account

  • Type: Account.Account | undefined

The account to send calls from. Defaults to client.account.

authorizeKeys

  • Type: readonly Key.Key[]

Additional keys to authorize on the account.

calls

  • Type: Calls[]

Array of calls to execute.

feeToken

  • Type: Address.Address

Token to use to cover fees.

key

  • Type: Key.Key

Key to sign the bundle with. If not provided, will attempt to find an appropriate key from the account.

merchantRpcUrl

  • Type: string

URL of the merchant to front the request (and sponsor calls if needed).

preCalls

  • Type: readonly PreCall[]

Calls to execute before the main bundle.

revokeKeys

  • Type: readonly Key.Key[]

Keys to revoke from the account.

Return Value

See wallet_sendPreparedCalls.