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
| Property | Type | Required | Description |
|---|---|---|---|
chainId | number | Yes | Chain ID for the account |
apiKey | string | Yes | API key for JAW services |
paymasterUrl | string | No | Custom 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 }
| Property | Type | Default | Description |
|---|---|---|---|
eip7702 | boolean | false | When 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):
- Creates a new smart account with a counterfactual address derived from the LocalAccount
- The smart account address is different from the LocalAccount address
- No delegation or authorization involved
EIP-7702 mode (eip7702: true):
- The smart account address equals the LocalAccount's EOA address
- On the first transaction, the SDK signs an EIP-7702 authorization to delegate the EOA's code to the JustanAccount implementation
- Registers the permissions manager as an owner
- Subsequent transactions skip delegation (already active)
In both modes:
- No passkey or WebAuthn involved
- No authentication state stored
getMetadata()returnsnull
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()orget())
Related
- EIP-7702 Guide — Full walkthrough with provider examples
- Account.get() — Passkey-based authentication
- Account.create() — Create passkey account
- getMetadata() — Returns null for LocalAccount-based accounts