/** * KEYSTONE: Universal Account — One Wallet, All Chains * * A single account identity that works across all 100+ supported chains. * Threshold keys (secp256k1 + ed25519) are generated once, and chain- * specific addresses are derived deterministically. Send any token on * any chain from one unified account, with automatic routing to the * optimal source chain. * * @example * ```typescript * import { UniversalAccountClient } from '@sequence0/sdk'; * * const ua = new UniversalAccountClient('http://agent:8080'); * * // Create a universal account * const account = await ua.createAccount({ * ownerSignature: '0x...', * timestamp: Date.now(), * }); * * // View all chain addresses * const addresses = await ua.getChainAddresses(account.accountId); * console.log('Ethereum:', addresses.ethereum.address); * console.log('Solana:', addresses.solana.address); * console.log('Bitcoin:', addresses.bitcoin.address); * * // Get unified balance across all chains * const balance = await ua.getUnifiedBalance(account.accountId); * for (const chain of balance.chains) { * console.log(`${chain.chain}: ${chain.nativeBalance} ${chain.nativeSymbol}`); * } * * // Send — automatic routing picks the best source chain * const result = await ua.send({ * accountId: account.accountId, * to: '0xRecipient...', * amount: '1.0', * token: 'ETH', * ownerSignature: '0x...', * timestamp: Date.now(), * }); * console.log('Tx:', result.txHash); * ``` */ /** * Address information for a single chain within a universal account. */ export interface ChainAddressInfo { /** Chain name (e.g., 'ethereum', 'bitcoin', 'solana') */ chain: string; /** Derived address on this chain */ address: string; /** Curve used for key derivation on this chain */ curveType: 'secp256k1' | 'ed25519'; /** Whether this chain address is currently active */ isActive: boolean; } /** * Full information about a universal account, including its * threshold parameters, group keys, and all derived chain addresses. */ export interface UniversalAccountInfo { /** Unique account identifier */ accountId: string; /** On-chain owner address (Ethereum address that controls this account) */ ownerAddress: string; /** Hex-encoded secp256k1 group public key */ secp256k1GroupKey: string; /** Hex-encoded ed25519 group public key */ ed25519GroupKey: string; /** Signing threshold (number of agents required to sign) */ threshold: number; /** Total committee size */ committeeSize: number; /** Map of chain name to chain address info */ chainAddresses: Record; /** Unix timestamp of account creation */ createdAt: number; /** Whether the account is currently active */ isActive: boolean; } /** * Balance information for a single token on a chain. */ export interface TokenBalance { /** Token symbol (e.g., 'USDC', 'WETH') */ symbol: string; /** Token contract address (undefined for native tokens) */ contractAddress?: string; /** Token balance as a decimal string */ balance: string; /** Token decimals */ decimals: number; } /** * Balance information for a single chain, including native token * and any tracked ERC-20 / SPL / equivalent token balances. */ export interface ChainBalance { /** Chain name */ chain: string; /** Account address on this chain */ address: string; /** Native token balance as a decimal string */ nativeBalance: string; /** Native token symbol (e.g., 'ETH', 'SOL', 'BTC') */ nativeSymbol: string; /** Token balances on this chain */ tokens: TokenBalance[]; /** Unix timestamp of last balance update */ lastUpdated: number; } /** * Aggregated balance view across all chains for a universal account. */ export interface UnifiedBalance { /** Account ID this balance belongs to */ accountId: string; /** Per-chain balance breakdown */ chains: ChainBalance[]; /** Total number of chains with balances */ totalChains: number; /** Unix timestamp of last aggregation */ lastAggregated: number; } /** * Options for sending tokens from a universal account. * The agent network automatically routes to the optimal source chain * based on available balances, fees, and latency. */ export interface UniversalSendOptions { /** Account ID to send from */ accountId: string; /** Destination address or account ID */ to: string; /** Amount to send as a decimal string */ amount: string; /** Token symbol (e.g., 'ETH', 'USDC', 'SOL', 'BTC') */ token: string; /** Optional preferred source chain (overrides automatic routing) */ preferredChain?: string; /** Owner signature authorizing this send */ ownerSignature: string; /** Unix timestamp of the signature */ timestamp: number; } /** * The routing decision made by the agent network for a send operation. * Describes which chain and address will be used as source and destination. */ export interface RoutingDecision { /** Source chain selected for this send */ sourceChain: string; /** Source address on the selected chain */ sourceAddress: string; /** Destination chain */ destinationChain: string; /** Destination address */ destinationAddress: string; /** Amount being sent */ amount: string; /** Token being sent */ token: string; /** Estimated fee in the source chain's native token */ estimatedFee: string; /** Human-readable reason for this routing choice */ reason: string; } /** * Result of a universal send operation. * * - `pending` — request received, queued for processing * - `routing` — agent is selecting the optimal source chain * - `signing` — threshold signing in progress * - `broadcasting` — signed transaction is being broadcast to the chain * - `confirmed` — transaction confirmed on-chain * - `failed` — send failed (check routing.reason for details) */ export type SendStatus = 'pending' | 'routing' | 'signing' | 'broadcasting' | 'confirmed' | 'failed'; export interface SendResult { /** Unique request identifier for polling status */ requestId: string; /** The routing decision (which chain, address, and fee) */ routing: RoutingDecision; /** Current status of the send operation */ status: SendStatus; /** Transaction hash (only when status is 'confirmed') */ txHash?: string; /** Hex-encoded threshold signature (only when status is 'confirmed' or 'broadcasting') */ signature?: string; } /** * Options for creating a new universal account. */ export interface CreateUniversalAccountOptions { /** Signing threshold (default: 16) */ threshold?: number; /** Total committee size (default: 24) */ committeeSize?: number; /** Owner signature authorizing account creation */ ownerSignature: string; /** Unix timestamp of the signature */ timestamp: number; } /** * Network-wide statistics for the Universal Account protocol. */ export interface UniversalAccountStats { /** Total number of universal accounts created */ totalAccounts: number; /** Total number of derived chain addresses across all accounts */ totalAddresses: number; /** Number of active (in-progress) send operations */ activeSends: number; } /** * Client for the KEYSTONE Universal Account protocol. * * Communicates with universal account endpoints on the agent node * to create accounts, query balances across all chains, and send * tokens with automatic chain routing. */ export declare class UniversalAccountClient { private baseUrl; /** * Create a new UniversalAccountClient. * * @param agentUrl - Agent node HTTP endpoint URL * @param options - Optional client configuration * @param options.timeout - Request timeout in milliseconds (default: 30000) */ constructor(agentUrl: string, options?: { timeout?: number; }); /** * Create a new universal account. * * Initiates DKG for both secp256k1 and ed25519 curves, derives * addresses on all 100+ supported chains, and registers the account * on the Sequence0 chain. * * @param options - Account creation options * @returns The created account information with all chain addresses * * @throws {Sequence0Error} If the creation parameters are invalid * @throws {NetworkError} If the agent is unreachable */ createAccount(options: CreateUniversalAccountOptions): Promise; /** * Get a universal account by its account ID. * * @param accountId - The unique account identifier * @returns The account information * * @throws {Sequence0Error} If the account ID is invalid * @throws {NetworkError} If the agent is unreachable or account not found */ getAccount(accountId: string): Promise; /** * Look up a universal account by any of its chain addresses. * * Given an address on any chain (Ethereum, Bitcoin, Solana, etc.), * returns the universal account that owns it. * * @param address - An address on any supported chain * @returns The account information, or null if no account owns this address * * @throws {Sequence0Error} If the address is invalid * @throws {NetworkError} If the agent is unreachable */ getAccountByAddress(address: string): Promise; /** * Get all universal accounts owned by a specific owner address. * * @param ownerAddress - The Ethereum owner address * @returns Array of account information objects * * @throws {Sequence0Error} If the owner address is invalid * @throws {NetworkError} If the agent is unreachable */ getOwnerAccounts(ownerAddress: string): Promise; /** * Deactivate a universal account. * * Marks the account as inactive. This does not destroy the keys * or chain addresses — it prevents new sends from being initiated. * Only the account owner can deactivate. * * @param accountId - The account ID to deactivate * @param ownerSignature - Owner signature authorizing deactivation * @param timestamp - Unix timestamp of the signature * * @throws {Sequence0Error} If parameters are invalid * @throws {NetworkError} If the agent is unreachable */ deactivateAccount(accountId: string, ownerSignature: string, timestamp: number): Promise; /** * Get all chain addresses for a universal account. * * @param accountId - The account ID * @returns Map of chain name to chain address info * * @throws {Sequence0Error} If the account ID is invalid * @throws {NetworkError} If the agent is unreachable */ getChainAddresses(accountId: string): Promise>; /** * Get the address for a specific chain within a universal account. * * @param accountId - The account ID * @param chain - The chain name (e.g., 'ethereum', 'bitcoin', 'solana') * @returns The chain address info * * @throws {Sequence0Error} If parameters are invalid * @throws {NetworkError} If the agent is unreachable */ getAddressForChain(accountId: string, chain: string): Promise; /** * Get unified balance across all chains for a universal account. * * Agents query balances on all chains where the account has * derived addresses and return an aggregated view. * * @param accountId - The account ID * @returns Unified balance with per-chain breakdown * * @throws {Sequence0Error} If the account ID is invalid * @throws {NetworkError} If the agent is unreachable */ getUnifiedBalance(accountId: string): Promise; /** * Get the balance for a specific chain within a universal account. * * @param accountId - The account ID * @param chain - The chain name (e.g., 'ethereum', 'bitcoin', 'solana') * @returns The chain balance * * @throws {Sequence0Error} If parameters are invalid * @throws {NetworkError} If the agent is unreachable */ getChainBalance(accountId: string, chain: string): Promise; /** * Send tokens from a universal account. * * The agent network automatically selects the optimal source chain * based on available balances, gas fees, and confirmation times. * Use `preferredChain` to override automatic routing. * * @param options - Send options * @returns The send result with routing decision and request ID for polling * * @throws {Sequence0Error} If the send parameters are invalid * @throws {NetworkError} If the agent is unreachable * * @example * ```typescript * const result = await ua.send({ * accountId: 'ua-abc123', * to: '0xRecipient...', * amount: '1.5', * token: 'ETH', * ownerSignature: '0x...', * timestamp: Date.now(), * }); * * // Poll for confirmation * const status = await ua.getSendStatus(result.requestId); * ``` */ send(options: UniversalSendOptions): Promise; /** * Get the current status of a send operation. * * @param requestId - The send request ID * @returns Current status of the send * * @throws {Sequence0Error} If the request ID is invalid * @throws {NetworkError} If the agent is unreachable */ getSendStatus(requestId: string): Promise; /** * Wait for a send operation to reach a terminal status by polling. * * Polls the send status endpoint at 2-second intervals until * the send is confirmed, fails, or the timeout is exceeded. * * @param requestId - The send request ID to wait for * @param timeout - Max time to wait in ms (default: 120000) * @returns The final send result * * @throws {TimeoutError} If the send is not completed within the timeout * @throws {Sequence0Error} If the send fails * @throws {NetworkError} If the agent is unreachable */ waitForSend(requestId: string, timeout?: number): Promise; /** * Preview the routing decision for a send without executing it. * * Use this to show users which chain will be used and the estimated * fee before they authorize the send with their signature. * * @param options - Send options (without ownerSignature and timestamp) * @returns The routing decision that would be made * * @throws {Sequence0Error} If the parameters are invalid * @throws {NetworkError} If the agent is unreachable * * @example * ```typescript * const route = await ua.previewRoute({ * accountId: 'ua-abc123', * to: '0xRecipient...', * amount: '1.5', * token: 'ETH', * }); * console.log(`Will send from ${route.sourceChain} (fee: ${route.estimatedFee})`); * ``` */ previewRoute(options: Omit): Promise; /** * Get network-wide Universal Account statistics. * * @returns Protocol statistics * * @throws {NetworkError} If the agent is unreachable */ getStats(): Promise; private get; private post; private mapAccountResponse; private mapChainAddressResponse; private mapChainBalanceResponse; private mapUnifiedBalanceResponse; private mapRoutingDecisionResponse; private mapSendResultResponse; } //# sourceMappingURL=universal-account.d.ts.map