Skip to content

Coinbase

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...')], 
})

nonce (optional)

  • Type: bigint

Nonce to use for the Smart Account.

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