Account Abstraction
Integrate Account Abstraction (ERC-4337) into viem.
While Account Abstraction is not built into the core viem
library, you can use a third-party library like permissionless.js to integrate with ERC-4337.
permissionless.js
permissionless.js is a TypeScript library built on viem for interacting with ERC-4337 bundlers, paymasters, and User Operations.
Below are instructions for setting up a Bundler Client.
1. Install
npm
npm i permissionless
2. Set up a Bundler Client
import { createClient, http } from 'viem'
import { mainnet } from 'viem/chains'
import { bundlerActions } from 'permissionless'
const bundlerClient = createClient({
chain: mainnet,
transport: http("https://api.pimlico.io/v1/goerli/rpc?apikey=YOUR_API_KEY_HERE")
}).extend(bundlerActions)
3. Consume Actions
Now you can consume Actions that are supported by permissionless.js.
See a full list of Bundler Actions.
import { createClient, http } from 'viem'
import { mainnet } from 'viem/chains'
import { bundlerActions } from 'permissionless'
const bundlerClient = createClient({
chain: mainnet,
transport: http("https://api.pimlico.io/v1/goerli/rpc?apikey=YOUR_API_KEY_HERE")
}).extend(bundlerActions)
const supportedEntryPoints = await bundlerClient.supportedEntryPoints()