Skip to content

RelayActions.sendPreparedCalls

Viem Action for broadcasting a prepared and signed call bundle. Uses wallet_sendPreparedCalls under the hood.

Usage

example.ts
import { RelayActions, Key } from 'porto/viem'
import { parseEther } from 'viem'
import { client } from './config'
 
// Create (or import) account
const key = Key.createP256()
const account = await RelayActions.createAccount(client, {
  authorizeKeys: [key],
})
 
// Prepare the calls
const request = await RelayActions.prepareCalls(client, {
  account,
  calls: [{
    to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
    value: parseEther('0.01'),
  }],
  key,
})
 
// Sign the digest 
const signature = await RelayActions.signCalls(request, { key }) 
 
// Send the prepared calls 
const result = await RelayActions.sendPreparedCalls(client, { 
  ...request, 
  signature, 
}) 

Parameters

context

  • Type: object

Context returned from RelayActions.prepareCalls.

key

  • Type: Pick<Key.Key, 'publicKey' | 'prehash' | 'type'>

Key used to sign the calls.

signature

  • Type: Hex.Hex

Signature over the digest from RelayActions.prepareCalls.

Return Value

See wallet_sendPreparedCalls.