Skip to content

Smart Account Client

A Smart Account Client is an almost drop-in replacement for a standard viem walletClient but for managing smart accounts instead of EOA accounts. In addition, a Smart Account Client also contains, depending on the underlying smart account implementation used, a few extra actions that are specific to smart accounts.

To create a Smart Account Client, use the createSmartAccountClient function.

Import

import { createSmartAccountClient } from 'permissionless'

Usage

Initialize a Smart Account Client with your desired account (which can be created using a function like signerToSimpleSmartAccount), chain, bundler transport, and optionally a sponsorUserOperation middleware by using the createSmartAccountClient method:

import { http } from 'viem'
import { sepolia } from 'viem/chains'
import { createSmartAccountClient } from "permissionless";
import { simpleSmartAccount } from "./simpleSmartAccount"; // created elsewhere
import { pimlicoPaymaster } from "./paymaster"; // created elsewhere
 
const smartAccountClient = createSmartAccountClient({
    account: simpleSmartAccount,
    chain: sepolia, // or whatever chain you are using
    transport: http("https://api.pimlico.io/v1/sepolia/rpc?apikey=YOUR_PIMLICO_API_KEY"),
    sponsorUserOperation: pimlicoPaymaster.sponsorUserOperation // if using a paymaster
})

Then you can consume Smart Account Actions and access properties:

const smartAccountAddress = await smartAccountClient.address