Caveat Enforcer Client reference
The following API methods are related to CaveatEnforcerClient used to check the delegation state.
createCaveatEnforcerClient
Create a Viem Client extended with caveat enforcer actions. This client allows you to interact with the caveat enforcers of the delegation, and read the required state.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
client | Client | Yes | The Viem Client to interact with the caveat enforcer contracts and read their state. |
environment | SmartAccountsEnvironment | Yes | Environment to resolve the smart contracts for the current chain. |
Example
- example.ts
- config.ts
import { environment, publicClient as client } from './config.ts'
import { createCaveatEnforcerClient } from '@metamask/smart-accounts-kit'
const caveatEnforcerClient = createCaveatEnforcerClient({
environment,
client,
})
import { sepolia as chain } from 'viem/chains'
import { createPublicClient, http } from 'viem'
import { getSmartAccountsEnvironment } from '@metamask/smart-accounts-kit'
export const environment = getSmartAccountsEnvironment(chain.id)
export const publicClient = createPublicClient({
chain,
transport: http(),
})