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
Use this for headless integration (No UI) + use this to issue smart wallets for AI Agents.
The Account class is ideal for:
- AI Agents - Issue programmable smart wallets for AI agents
- Headless Integration - No UI required, direct programmatic access
- React Native - Native mobile passkey support via
nativeGetFnandnativeCreateFn— see the React Native guide - Server-side Applications - Using
fromLocalAccount()with embedded wallets (Privy, Dynamic, Turnkey) - Custom UI Handlers - When implementing your own
UIHandlerfor app-specific mode - 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
Import
The Account class is exported from @jaw.id/core:
import { Account } from '@jaw.id/core';
// React Native: also import adapter types
import type { NativePasskeyGetFn, NativePasskeyCreateFn, SyncStorage } from '@jaw.id/core';Static Methods
Factory methods for creating Account instances:
| Method | Description |
|---|---|
| Account.get() | Get account - restores session or triggers login |
| Account.create() | Create new account with passkey |
| Account.import() | Import passkey from cloud backup |
| Account.restore() | Restore account from credential data (no WebAuthn prompt) |
| Account.fromLocalAccount() | Create from viem LocalAccount (server-side) |
Utility methods:
| Method | Description |
|---|---|
| Account.getAuthenticatedAddress() | Get current authenticated address |
| Account.getCurrentAccount() | Get current authenticated account data |
| Account.getStoredAccounts() | Get all stored passkey accounts |
| Account.logout() | Clear authentication state |
Instance Properties
| Property | Type | Description |
|---|---|---|
address | Address | Smart account address |
chainId | number | Current chain ID |
Instance Methods
Information
| Method | Description |
|---|---|
| getMetadata() | Get account metadata (username, creation date) |
| getSmartAccount() | Get underlying viem SmartAccount |
| getChain() | Get chain configuration |
| getAddress() | Get address (async, for counterfactual) |
Signing
| Method | Description |
|---|---|
| signMessage() | Sign a personal message (EIP-191) |
| signTypedData() | Sign typed data (EIP-712) |
Transactions
| Method | Description |
|---|---|
| sendTransaction() | Send transaction and wait for receipt |
| sendCalls() | Send bundled calls (returns immediately) |
| estimateGas() | Estimate gas for calls |
Permissions
| Method | Description |
|---|---|
| grantPermissions() | Grant permissions to a spender |
| revokePermission() | Revoke a permission |
| getPermission() | Get permission details |
Interfaces
AccountConfig
Configuration for creating or loading an account. React Native options (nativeGetFn, nativeCreateFn, rpId) are configured once here and shared across all static methods.
apiKey is optional on the type because whether a request is served is the backend's decision rather than the SDK's. Which methods work without one is a separate question, answered per method: the passkey flows are refused without a key, and fromLocalAccount is not. Each method's own page says which.
interface AccountConfig {
/** Chain ID for the account */
chainId: number;
/** API key for JAW services, if the caller has one */
apiKey?: string;
/** Custom paymaster URL for gas sponsorship */
paymasterUrl?: string;
/** Custom paymaster context for gas sponsorship */
paymasterContext?: Record<string, unknown>;
/** Custom storage implementation (defaults to localStorage on web, in-memory fallback in React Native) */
storage?: SyncStorage;
/** Native passkey get function for React Native (e.g. Passkey.get) */
nativeGetFn?: NativePasskeyGetFn;
/** Native passkey create function for React Native (e.g. Passkey.create) */
nativeCreateFn?: NativePasskeyCreateFn;
/** Relying party identifier (defaults to window.location.hostname). Required in React Native. */
rpId?: string;
/** Relying party name (defaults to 'JAW') */
rpName?: string;
}CreateAccountOptions
Options for creating a new account:
interface CreateAccountOptions {
/** Username/display name for the passkey */
username: 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;
/** Credential ID of the passkey */
credentialId: 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 ETHUse parseEther() from viem to convert human-readable ETH amounts to wei.
Related
- Custom UI Handler - Build custom UI with Account class
- Provider - RPC Reference - Provider-based RPC methods