RelayActions.createAccount
Viem Action for instantiating a new Porto Account. Uses wallet_prepareUpgradeAccount
and wallet_upgradeAccount
under the hood.
Usage
example.ts
import { RelayActions, Key } from 'porto/viem'
import { client } from './config'
const account = await RelayActions.createAccount(client, {
authorizeKeys: [Key.createSecp256k1()],
})
Parameters
authorizeKeys
- Type:
readonly Key.Key[]
Keys to authorize on the account.
delegation
- Type:
Address.Address
Delegation address for the account.
feeToken
- Type:
'native' | Token.Symbol | Address.Address
Token to use to cover fees. Accepts:
"native"
(Default): The native token of the chain.- Symbol: Symbol of the fee token (e.g.
"USDC"
). - Address: Address of the fee token (e.g.
"0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
).
Return Value
type CreateAccountReturnType = {
/** Account address */
address: `0x${string}`
/** Authorized keys on the account */
keys: Key.Key[]
/** Account type */
type: 'porto'
}
Returns a new Porto Account with the specified authorized keys.