/** * Fee Manager * * Reads the FeeCollector contract on the Sequence0 chain to query fee * parameters (rate, split ratios) and resolve agent payment addresses. * The actual fee is collected on the TARGET CHAIN in its native token -- * it is built into the signed transaction itself as an extra output/transfer. * * Sequence0 Fee Model: * - Fee = 30% of target chain's estimated gas cost * - Paid in the target chain's native token * - Split: 80% agents, 10% reserve, 1% makers, 9% treasury rewards * - Example: Ethereum ($2 gas) -> $0.60 signing fee * - Example: Solana ($0.00025 gas) -> $0.000075 signing fee * - Example: Bitcoin ($5 gas) -> $1.50 signing fee * * Fully decentralized: reads directly from on-chain contracts, no backend. * * @example * ```typescript * const fee = new FeeManager({ * rpcUrl: 'https://mainnet-rpc.sequence0.network', * feeCollectorAddress: '0x3e75670126a4a5eB33b8aD146908948bDCad0B17', * registryAddress: '0x7417cfe808d98840d90e0fc7dfc998b5cc30d64f', * }); * * // Get the current per-signature fee * const feeWei = await fee.getSignatureFee(); * * // Build an unsigned fee TX for a wallet's committee * const tx = await fee.buildCollectFeeTx('my-wallet', ['0xAgent1', '0xAgent2']); * // => { to, data, value } -- sign and send with your own wallet * ``` */ export interface FeeManagerOptions { /** Sequence0 chain RPC URL */ rpcUrl: string; /** FeeCollector proxy contract address */ feeCollectorAddress: string; /** AgentRegistry proxy contract address (for resolving peer IDs to payment addresses) */ registryAddress: string; /** Fee cache TTL in ms (default: 300000 = 5 minutes) */ cacheTtl?: number; } /** Unsigned transaction object that the app developer signs and sends */ export interface UnsignedFeeTx { /** FeeCollector contract address */ to: string; /** ABI-encoded calldata for collectFee(walletId, agents) */ data: string; /** Fee amount in wei (hex string) */ value: string; } export declare class FeeManager { private rpcUrl; private feeCollectorAddress; private registryAddress; private cacheTtl; private feeCache; constructor(options: FeeManagerOptions); /** * Get the current per-signature fee from the FeeCollector contract. * Result is cached for 5 minutes (configurable via cacheTtl). * * Note: This returns the fee rate parameter from the on-chain contract. * The actual signing fee (30% of the target chain's estimated gas cost) * is collected on the target chain in its native token, built into the * signed transaction by the agent network at signing time. * * @returns Fee in wei as a bigint */ getSignatureFee(): Promise; /** * Build an unsigned collectFee transaction. * * The fee is collected on the target chain in its native token, built * directly into the signed transaction. The FeeCollector on the Sequence0 * chain is used for governance (fee rates, split ratios) and accounting. * * @param walletId - The Sequence0 wallet ID being signed for * @param agents - Array of agent Ethereum addresses (payment addresses) * @returns Unsigned transaction { to, data, value } */ buildCollectFeeTx(walletId: string, agents: string[]): Promise; /** * Resolve committee peer IDs to their Ethereum payment addresses * by reading the AgentRegistry contract. * * @param peerIds - Array of libp2p peer IDs from a wallet's committee * @returns Array of Ethereum payment addresses (same order; empty string if not found) */ resolveAgentPaymentAddresses(peerIds: string[]): Promise; /** * Estimate the signing fee for a specific chain. * Fees are collected on the target chain in its native token. * App developers do NOT need to send separate fee transactions. */ estimateFee(chain: string, estimatedGasCost: bigint): Promise<{ feeAmount: bigint; feePercentage: number; tokenSymbol: string; }>; /** * Invalidate the cached fee so the next call re-fetches from chain. */ clearCache(): void; /** * Look up a single agent's payment address from the AgentRegistry. * The `agents(string)` public mapping getter returns the Agent struct. * * Struct layout: * string multiaddr (dynamic, offset at slot 0) * address paymentAddress (slot 1) * uint256 registeredAt (slot 2) * uint256 lastHeartbeat (slot 3) * bool isActive (slot 4) * uint64 heartbeatCount (packed in slot 4) * uint64 signaturesParticipated (packed in slot 4) */ private getAgentPaymentAddress; /** * ABI-encode calldata for collectFee(string walletId, address[] agents) */ private encodeCollectFee; /** * Make an eth_call to the Sequence0 chain RPC. */ private ethCall; } //# sourceMappingURL=fee.d.ts.map