1.5 KiB

WebAuthn Account

A WebAuthn Account is nearly identical to a Local Account, but with the following differences:

  • uses the secp256r1 curve for signatures
  • returns a signature as well as webauthn data in its signing methods
  • cannot sign transactions (transactions do not support secp256r1 signatures)
  • does not have an Ethereum address

WebAuthn Accounts are commonly used for Smart Account Owners to sign User Operations and messages on behalf of the Smart Account.

:::note WebAuthn Account owners are currently supported on the following Smart Account implementations:

Usage

:::code-group

import { 
  createWebAuthnCredential, 
  toWebAuthnAccount,
  toCoinbaseSmartAccount 
} from 'viem/account-abstraction'
import { client } from './client'

// 1. Register a credential (ie. passkey).
const credential = await createWebAuthnCredential({
  name: 'Example',
})

// 2. Create a WebAuthn owner account from the credential.
const owner = toWebAuthnAccount({
  credential,
})

// 3. Hook up the owner to a WebAuthn-compatible Smart Account.
const account = toCoinbaseSmartAccount({
  client,
  owners: [owner],
  version: '1.1',
})
import { createPublicClient, http } from 'viem'
import { mainnet } from 'viem/chains'

export const client = createPublicClient({
  chain: mainnet,
  transport: http(),
})

:::