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.fromLocalAccount()

Create an account from a Viem LocalAccount. Ideal for server-side usage or integration with embedded wallet providers.

Type: static async

Signature

static async fromLocalAccount(
  config: AccountConfig,
  localAccount: LocalAccount,
  options?: { eip7702?: boolean }
): Promise<Account>

Parameters

config

Type: AccountConfig

PropertyTypeRequiredDescription
chainIdnumberYesChain ID for the account
apiKeystringYesAPI key for JAW services
paymasterUrlstringNoCustom paymaster URL for gas sponsorship

localAccount

Type: LocalAccount (from viem)

A viem LocalAccount instance. Can be created from:

  • Private key
  • Mnemonic
  • Embedded wallet providers (Privy, Turnkey, Magic, etc.)

options (optional)

Type: { eip7702?: boolean }

PropertyTypeDefaultDescription
eip7702booleanfalseWhen true, preserves the EOA address via EIP-7702 delegation instead of creating a new counterfactual address

Returns

Promise<Account> - The Account instance

Behavior

Default mode (eip7702: false or omitted):

  1. Creates a new smart account with a counterfactual address derived from the LocalAccount
  2. The smart account address is different from the LocalAccount address
  3. No delegation or authorization involved

EIP-7702 mode (eip7702: true):

  1. The smart account address equals the LocalAccount's EOA address
  2. On the first transaction, the SDK signs an EIP-7702 authorization to delegate the EOA's code to the JustanAccount implementation
  3. Registers the permissions manager as an owner
  4. Subsequent transactions skip delegation (already active)

In both modes:

  • No passkey or WebAuthn involved
  • No authentication state stored
  • getMetadata() returns null

Examples

Default — New Smart Account Address

import { Account } from '@jaw.id/core';
import { privateKeyToAccount } from 'viem/accounts';
 
const localAccount = privateKeyToAccount('0x...');
 
const account = await Account.fromLocalAccount({ chainId: 8453, apiKey: 'your-api-key' }, localAccount);
 
// account.address !== localAccount.address (new counterfactual address)
console.log('Smart account address:', account.address);

EIP-7702 — Preserve EOA Address

import { Account } from '@jaw.id/core';
import { privateKeyToAccount } from 'viem/accounts';
 
const localAccount = privateKeyToAccount('0x...');
 
const account = await Account.fromLocalAccount({ chainId: 8453, apiKey: 'your-api-key' }, localAccount, {
  eip7702: true,
});
 
// account.address === localAccount.address (EOA address preserved)
console.log('Address:', account.address);

When to Use

Use fromLocalAccount() when:

  • Server-side automation — Backend services that need to execute transactions
  • Embedded wallets — Integrating with Privy, Turnkey, Magic, etc.
  • EIP-7702 upgrade — Upgrading an existing EOA to a smart account while keeping the same address

Use { eip7702: true } when:

  • Preserving address matters — The user's EOA address has history, reputation, or token balances they want to keep
  • Provider integration — The wallet provider gives you a LocalAccount and the user expects their address to stay the same

Do not use when:

  • You want passkey-based authentication (use create() or get())

Related