Viem
Overview

Viem

After instantiating the SDK (which is explained here), you're allowed to use the following methods from viem.

💡
To use the following methods, please make sure the user is authenticated.

toLocalAccount()

Parameters

void

Returns

Promise<LocalAccount> (see LocalAccount (opens in a new tab))

Example

const user = await sdk.viem.toLocalAccount();

toSmartAccount()

Parameters

CurrentUserToLightSmartAccountParams

Returns

Promise<LightSmartAccount> (see LocalAccount (opens in a new tab))

Example

import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
 
const client = createPublicClient({
  chain: mainnet,
  transport: http("YOUR_RPC_URL"),
});
 
const smartAccount = await sdk.viem.toSmartAccount({
  owner: localAccount, // from `toLocalAccount()`
  client,
});

getPaymasterClient()

Parameters

void

Returns

Promise<PaymasterClient> (see PaymasterClient (opens in a new tab))

Example

import { PaymasterClient } from "viem/account-abstraction";
 
const paymasterClient: PaymasterClient = await sdk.viem.getPaymasterClient();