ServerActions.prepareCalls
Viem Action for preparing a bundle of calls for execution. Uses wallet_prepareCalls
under the hood.
Usage
example.ts
import { ServerActions, Key } from 'porto/viem'
import { parseEther } from 'viem'
import { client, account } from './config'
const key = Key.createSecp256k1()
const prepared = await ServerActions.prepareCalls(client, {
account,
calls: [{
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('0.01'),
}],
key,
})
Parameters
account
- Type:
Account.Account | undefined
The account to prepare calls for. Defaults to client.account
.
authorizeKeys
- Type:
readonly Key.Key[]
Additional keys to authorize on the account.
calls
- Type:
Calls[]
Array of calls to prepare for execution.
feeToken
- Type:
Address.Address
Token to use for transaction fees.
permissionsFeeLimit
- Type:
bigint
Fee limit for permissions.
preCalls
- Type:
true | readonly { context: ServerActions.prepareCalls.ReturnType['context'], signature: Hex.Hex }[]
Indicates if the bundle is "pre-calls", and should be executed before the main bundle.
Accepts:
true
: Indicates this is a "pre-calls" bundle to prepare.- An array: Set of signed and prepared "pre-calls".
key
- Type:
Pick<Key.Key, 'publicKey' | 'prehash' | 'type'>
Key that will be used to sign the calls.
merchantRpcUrl
- Type:
string
URL of the merchant to front the request (and sponsor calls if needed).
revokeKeys
- Type:
readonly Key.Key[]
Keys to revoke from the account.
Return Value
See wallet_prepareCalls
.