Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Account

The Account class provides a low-level API for smart account operations. It's the recommended way to interact with JAW smart accounts when building custom UI handlers or server-side applications.

When to Use Account

The Account class is ideal for:

  • Custom UI Handlers - When implementing your own UIHandler for app-specific mode
  • Server-side Applications - Using fromLocalAccount() with embedded wallets (Privy, Dynamic, Turnkey)
  • Direct Integration - When you need fine-grained control over account operations

For standard client-side usage with the built-in UI, use the provider-based API instead.

Installation

npm
npm install @jaw.id/core viem

Import

The Account class is exported from @jaw.id/core:

import { Account } from '@jaw.id/core';

Static Methods

Factory methods for creating Account instances:

MethodDescription
Account.get()Get account - restores session or triggers login
Account.create()Create new account with passkey
Account.import()Import passkey from cloud backup
Account.fromLocalAccount()Create from viem LocalAccount (server-side)

Utility methods:

MethodDescription
Account.getAuthenticatedAddress()Get current authenticated address
Account.getStoredAccounts()Get all stored passkey accounts
Account.logout()Clear authentication state

Instance Properties

PropertyTypeDescription
addressAddressSmart account address
chainIdnumberCurrent chain ID

Instance Methods

Information

MethodDescription
getMetadata()Get account metadata (username, creation date)
getSmartAccount()Get underlying viem SmartAccount
getChain()Get chain configuration
getAddress()Get address (async, for counterfactual)

Signing

MethodDescription
signMessage()Sign a personal message (EIP-191)
signTypedData()Sign typed data (EIP-712)

Transactions

MethodDescription
sendTransaction()Send transaction and wait for receipt
sendCalls()Send bundled calls (returns immediately)
estimateGas()Estimate gas for calls

Permissions

MethodDescription
grantPermissions()Grant permissions to a spender
revokePermission()Revoke a permission
getPermission()Get permission details

Interfaces

AccountConfig

Configuration for creating or loading an account:

interface AccountConfig {
  /** Chain ID for the account */
  chainId: number;
  /** API key for JAW services (required) */
  apiKey: string;
  /** Custom paymaster URL for gas sponsorship */
  paymasterUrl?: string;
}

CreateAccountOptions

Options for creating a new account:

interface CreateAccountOptions {
  /** Username/display name for the passkey */
  username: string;
  /** Relying party identifier (defaults to window.location.hostname) */
  rpId?: string;
  /** Relying party name (defaults to 'JAW') */
  rpName?: string;
}

TransactionCall

Transaction call structure:

interface TransactionCall {
  /** Target contract address */
  to: Address;
  /** Value to send in wei (bigint or hex string) */
  value?: bigint | string;
  /** Call data */
  data?: Hex;
}

AccountMetadata

Account metadata returned by getMetadata():

interface AccountMetadata {
  /** Username/display name */
  username: string;
  /** ISO date string when created */
  creationDate: string;
  /** Whether imported from cloud */
  isImported: boolean;
}

Value Format

The value field in TransactionCall must be in wei (the smallest unit of ETH):

import { parseEther } from 'viem';
 
// BigInt (wei)
{ to: '0x...', value: 1000000000000000000n }  // 1 ETH in wei
 
// Hex string (wei)
{ to: '0x...', value: '0x0de0b6b3a7640000' }  // 1 ETH in wei
 
// Using parseEther for convenience
{ to: '0x...', value: parseEther('1') }    // 1 ETH
{ to: '0x...', value: parseEther('0.1') }  // 0.1 ETH

Use parseEther() from viem to convert human-readable ETH amounts to wei.

Related