Wallet Overview
The ONE SDK wallet module provides a unified interface for creating and managing wallets across multiple EVM chains. You can work with smart wallets (account abstraction) or traditional EOA wallets, depending on your application's needs.
Smart Wallet vs EOA Wallet
| Feature | Smart Wallet | EOA Wallet |
|---|---|---|
| Account abstraction | Yes (ERC-4337) | No |
| Gas sponsorship | Yes | No |
| Batch transactions | Yes | No |
| Social recovery | Yes | No |
| Key type | Contract-based | Private key |
| Deployment | On first transaction | Instant |
Creating a Wallet
Use the createWallet method from the engine client to create a new wallet.
import { useOneClient } from '@one_deploy/sdk';
function CreateWalletExample() {
const { engineClient } = useOneClient();
const handleCreateSmartWallet = async () => {
const wallet = await engineClient.createWallet(
CHAIN_IDS.BASE, // chainId
'smart' // type: 'smart' | 'eoa'
);
console.log('Wallet address:', wallet.address);
console.log('Wallet type:', wallet.type); // 'smart'
console.log('Chain ID:', wallet.chainId); // 8453
};
const handleCreateEOAWallet = async () => {
const wallet = await engineClient.createWallet(
CHAIN_IDS.ETHEREUM,
'eoa'
);
console.log('EOA address:', wallet.address);
};
return (
<div>
<button onClick={handleCreateSmartWallet}>Create Smart Wallet</button>
<button onClick={handleCreateEOAWallet}>Create EOA Wallet</button>
</div>
);
}
Method Signature
createWallet(chainId: number, type: 'smart' | 'eoa'): Promise<Wallet>
Parameters:
| Parameter | Type | Description |
|---|---|---|
chainId | number | The chain ID to create the wallet on. Use the CHAIN_IDS constant. |
type | 'smart' | 'eoa' | The wallet type. 'smart' enables account abstraction features. |
Returns: Promise<Wallet>
interface Wallet {
address: string;
type: 'smart' | 'eoa';
chainId: number;
createdAt: string;
status: 'active' | 'pending_deployment';
}
Multi-Chain Support
The ONE SDK supports the following chains out of the box:
import { CHAIN_IDS } from '@one_deploy/sdk';
// Mainnets
CHAIN_IDS.BASE; // 8453
CHAIN_IDS.ETHEREUM; // 1
CHAIN_IDS.POLYGON; // 137
CHAIN_IDS.ARBITRUM; // 42161
CHAIN_IDS.OPTIMISM; // 10
// Testnets
CHAIN_IDS.BASE_SEPOLIA; // 84532
CHAIN_IDS.ETHEREUM_SEPOLIA; // 11155111
CHAIN_IDS.POLYGON_AMOY; // 80002
CHAIN_IDS.ARBITRUM_SEPOLIA; // 421614
CHAIN_IDS.OPTIMISM_SEPOLIA; // 11155420
A single wallet address can be used across all supported chains. Smart wallets are deployed per chain on first use.
Smart Wallet and Gas Sponsorship
Smart wallets created through the ONE SDK support gas sponsorship via a paymaster. When gas sponsorship is enabled on your project (configured in the Dashboard), your users can send transactions without holding native tokens for gas.
import { useOneClient, CHAIN_IDS } from '@one_deploy/sdk';
function GasSponsoredTransaction() {
const { engineClient } = useOneClient();
const handleSend = async () => {
// Gas is automatically sponsored for smart wallets
// when enabled in your project settings
const tx = await engineClient.sendTransaction({
fromAddress: '0xYourSmartWallet...',
toAddress: '0xRecipient...',
chainId: CHAIN_IDS.BASE,
value: '0.01',
currency: 'ETH',
});
console.log('Transaction hash:', tx.transactionHash);
};
return <button onClick={handleSend}>Send (Gasless)</button>;
}
Fetching User Wallets
Retrieve all wallets associated with the authenticated user.
import { useOneClient } from '@one_deploy/sdk';
function UserWallets() {
const { engineClient } = useOneClient();
const loadWallets = async () => {
const wallets = await engineClient.getUserWallets();
wallets.forEach((wallet) => {
console.log(`${wallet.type} wallet on chain ${wallet.chainId}: ${wallet.address}`);
});
};
return <button onClick={loadWallets}>Load My Wallets</button>;
}
Method Signature
getUserWallets(): Promise<Wallet[]>
Returns an array of all Wallet objects for the currently authenticated user, across all chains.
CHAIN_IDS Constant
The CHAIN_IDS constant provides a type-safe way to reference supported chains:
import { CHAIN_IDS } from '@one_deploy/sdk';
type ChainId = typeof CHAIN_IDS[keyof typeof CHAIN_IDS];
// Usage in typed functions
function getChainName(chainId: ChainId): string {
switch (chainId) {
case CHAIN_IDS.BASE: return 'Base';
case CHAIN_IDS.ETHEREUM: return 'Ethereum';
case CHAIN_IDS.POLYGON: return 'Polygon';
case CHAIN_IDS.ARBITRUM: return 'Arbitrum';
case CHAIN_IDS.OPTIMISM: return 'Optimism';
default: return 'Unknown';
}
}
Next Steps
- Connect Button -- Add a sign-in button to your app.
- Balance Display -- Show wallet balances.
- Send Crypto -- Send tokens from a wallet.
- Mobile & Desktop -- Understand platform differences.