RelayActions.sendCalls
Viem Action for broadcasting a call bundle to the Relay. This is a convenience function that prepares, signs, and sends calls in one operation.
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],
})
const result = await RelayActions.sendCalls(client, {
account,
calls: [{
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('0.01'),
}],
key, // // Optional for EOA accounts
})
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:
'native' | Token.Symbol | Address.Address
Token to use to cover fees. Accepts:
"native"
: The native token of the chain.- Symbol: Symbol of the fee token (e.g.
"USDC"
). - Address: Address of the fee token (e.g.
"0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
).
key
- Type:
Key.Key | undefined
(optional)
Key to sign the bundle with. If not provided, will use the account's built-in signing capability (for EOA accounts) or attempt to find an appropriate key from the account.
merchantUrl
- 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.
requiredFunds
- Type:
readonly ({ address: "0x${string}"; value: "0x${string}" } | { symbol: string; value: string })[]
Funds required on the target chain.
revokeKeys
- Type:
readonly Key.Key[]
Keys to revoke from the account.