Skip to main content

Method Signature

agent.createSmartAccount(params: CreateSmartAccountParams): Promise<SmartAccountInfo>

Description

Creates a new smart account for a user’s origin wallet.
Smart accounts are deterministic - the same origin wallet always generates the same smart account address. It’s safe to call this method multiple times.

Parameters

origin_wallet
Address
required
User’s origin wallet address (EOA or smart wallet). Must be a valid Ethereum address starting with 0x followed by 40 hexadecimal characters.Example: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e"

Return Value

Returns a Promise<SmartAccountInfo> with:
smartAccountAddress
Address
The smart account contract address. This is where users deposit funds.
backendWallet
Address
Backend wallet address that manages the smart account via session keys.
origin_wallet
Address
The origin wallet address that owns the smart account.
chain
Chain
Chain ID where the smart account exists.

Example

import { GizaAgent, Chain } from '@giza/agent-sdk';

const giza = new GizaAgent({ chainId: Chain.BASE });

const account = await giza.agent.createSmartAccount({
  origin_wallet: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e'
});

console.log('Smart Account:', account.smartAccountAddress);
console.log('Backend Wallet:', account.backendWallet);
console.log('Origin Wallet:', account.origin_wallet);
console.log('Chain:', account.chain);

// Display to user
console.log(`Deposit USDC to: ${account.smartAccountAddress}`);

Output

{
  smartAccountAddress: '0xabc123...',
  backendWallet: '0xdef456...',
  origin_wallet: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
  chain: 8453
}

Error Handling

import { ValidationError, GizaAPIError } from '@giza/agent-sdk';

try {
  const account = await giza.agent.createSmartAccount({
    origin_wallet: userWallet
  });
} catch (error) {
  if (error instanceof ValidationError) {
    // Invalid wallet address format
    console.error('Invalid wallet address:', error.message);
  } else if (error instanceof GizaAPIError) {
    // API error
    console.error('Failed to create smart account:', error.message);
  }
}

Common Errors

ErrorCauseSolution
ValidationError: origin wallet address is requiredMissing origin_wallet parameterProvide a valid origin_wallet address
ValidationError: origin wallet address must be a valid Ethereum addressInvalid address formatEnsure address starts with 0x and has 40 hex characters
GizaAPIError: UnauthorizedInvalid API credentialsCheck GIZA_API_KEY and GIZA_PARTNER_NAME

Next Steps