Skip to content

Coinbase Smart Wallet

The toCoinbaseSmartAccount implementation references the Coinbase Smart Wallet contract.

Usage

example.ts
import { toCoinbaseSmartAccount } from 'viem/account-abstraction'
import { client } from './client.js'
import { owner } from './owner.js'
 
const account = await toCoinbaseSmartAccount({ 
  client, 
  owners: [owner], 
}) 

Returns

SmartAccount<CoinbaseSmartAccountImplementation>

Parameters

client

  • Type: Client

Client used to retrieve Smart Account data.

const client = createPublicClient({ 
  chain: mainnet, 
  transport: http(), 
}) 
 
const account = await toCoinbaseSmartAccount({
  client, 
  owners: [owner],
})

owners

  • Type: (LocalAccount | WebAuthnAccount)[]

Owners of the Smart Account. Can be a Local Account or a WebAuthn Account (Passkey).

const account = await toCoinbaseSmartAccount({
  client,
  owners: [privateKeyToAccount('0x...')], 
})

ownerIndex (optional)

  • Type: number

Index of the owner to use for signing messages & User Operations.

const account = await toCoinbaseSmartAccount({
  client,
  owners: [privateKeyToAccount('0x...'), privateKeyToAccount('0x...')],
  ownerIndex: 1, 
})

nonce (optional)

  • Type: bigint

Nonce to use for the Smart Account.

const account = await toCoinbaseSmartAccount({
  client,
  owners: [owner],
  nonce: 1n, 
})