/** * ERC-4337 UserOperation Builder for TotalReclaw. * * Builds and submits UserOperations via a SimpleSmartAccount (ERC-4337 v0.7) * to write encrypted facts on-chain through the EventfulDataEdge contract. * * Architecture: * - UserOp building and signing happens CLIENT-SIDE using `permissionless` + `viem` * - Sponsorship via Pimlico paymaster, proxied through the TotalReclaw relay server * - The relay server proxies bundler/paymaster JSON-RPC and handles billing * - Clients never need a Pimlico API key -- the relay holds the key server-side * * Flow: * 1. Client encrypts fact + serializes to Protobuf (existing code) * 2. This module wraps the encrypted bytes into a UserOperation * 3. The UserOp is built via a SimpleSmartAccount (handles initCode, gas, signing) * 4. The UserOp is sponsored by Pimlico paymaster (via relay proxy) * 5. The signed UserOp is submitted to the relay's bundler endpoint * 6. Relay forwards to Pimlico bundler -> chain -> EventfulDataEdge * * Key addresses: * - EntryPoint v0.7: 0x0000000071727De22E5E9d8BAf0edAc6f37da032 * - SimpleAccountFactory v0.7: 0x91E60e0613810449d098b0b5Ec8b51A0FE8c8985 * - SimpleAccount implementation: 0xe6Cae83BdE06E4c305530e199D7217f42808555B * * Dependencies: * - permissionless (Pimlico SDK for ERC-4337) * - viem (Ethereum interactions, signing, encoding) */ /** EntryPoint v0.7 -- canonical singleton across all EVM chains */ export declare const ENTRYPOINT_V07_ADDRESS: "0x0000000071727De22E5E9d8BAf0edAc6f37da032"; /** SimpleAccountFactory v0.7 -- canonical factory for SimpleAccount */ export declare const SIMPLE_ACCOUNT_FACTORY_V07_ADDRESS: "0x91E60e0613810449d098b0b5Ec8b51A0FE8c8985"; /** SimpleAccount v0.7 implementation (logic contract) */ export declare const SIMPLE_ACCOUNT_IMPLEMENTATION_ADDRESS: "0xe6Cae83BdE06E4c305530e199D7217f42808555B"; export interface UserOperationConfig { /** 32-byte private key derived from BIP-39 seed */ privateKey: Buffer; /** EventfulDataEdge contract address */ dataEdgeAddress: `0x${string}`; /** Chain ID (100 for Gnosis, 10200 for Chiado, 84532 for Base Sepolia) */ chainId: number; /** Encrypted Protobuf payload to write on-chain */ encryptedPayload: Buffer; /** TotalReclaw relay server URL (proxies bundler + paymaster JSON-RPC) */ serverUrl: string; /** Optional: override nonce (for sequential operations) */ nonce?: bigint; } export interface UserOperationResult { /** Hex-encoded calldata (the encrypted payload) */ callData: string; /** Target contract address */ target: string; /** Operation nonce */ nonce: bigint; /** Sender (Smart Account) address */ sender: string; /** UserOperation hash returned by the bundler */ userOpHash: string; } export interface SendFactConfig { /** 32-byte private key derived from BIP-39 seed */ privateKey: Buffer; /** EventfulDataEdge contract address */ dataEdgeAddress: `0x${string}`; /** Chain ID (100 for Gnosis, 10200 for Chiado, 84532 for Base Sepolia) */ chainId: number; /** Encrypted Protobuf payload to write on-chain */ encryptedPayload: Buffer; /** TotalReclaw relay server URL (proxies bundler + paymaster JSON-RPC) */ serverUrl: string; /** Timeout in ms to wait for on-chain confirmation (default: 60_000) */ timeout?: number; } /** * Encode an encrypted fact as hex calldata for the EventfulDataEdge fallback(). * * The EventfulDataEdge contract uses a fallback() function, so the calldata * IS the encrypted payload directly (no function selector). * * @param encryptedBlob - Encrypted Protobuf bytes * @returns Hex-encoded calldata string (0x-prefixed) */ export declare function encodeFactAsCalldata(encryptedBlob: Buffer): string; /** * Compute the deterministic Smart Account address for a given EOA owner * address and chain ID. * * This calls the SimpleAccountFactory.getAddress() **view function**, which is * a pure CREATE2 computation on-chain. It requires an RPC connection but does * NOT cost gas (it's an eth_call, not a transaction). * * The address is deterministic: same owner + same salt (0) = same address on * every chain where the factory is deployed. * * @param ownerAddress - EOA address that will own the Smart Account * @param chainId - Chain ID (100 for Gnosis, 10200 for Chiado, 84532 for Base Sepolia) * @param salt - Account index / salt (default: 0n) * @returns Deterministic Smart Account address (checksummed hex) */ export declare function getSmartAccountAddress(ownerAddress: `0x${string}`, chainId: number, salt?: bigint): Promise; /** * Compute the deterministic Smart Account address from a private key. * * Convenience wrapper that derives the EOA address from the private key * and then calls getSmartAccountAddress(). * * @param privateKey - 32-byte private key (Buffer) * @param chainId - Chain ID (100 for Gnosis, 10200 for Chiado, 84532 for Base Sepolia) * @param salt - Account index / salt (default: 0n) * @returns Deterministic Smart Account address (checksummed hex) */ export declare function getSmartAccountAddressFromKey(privateKey: Buffer, chainId: number, salt?: bigint): Promise; /** * Build an ERC-4337 UserOperation for writing an encrypted fact on-chain. * * This creates a SmartAccountClient backed by a SimpleSmartAccount, then * submits the UserOperation to the Pimlico bundler with paymaster sponsorship. * * The SimpleSmartAccount: * - Automatically generates initCode for first-time users (factory deployment) * - Uses the canonical SimpleAccountFactory v0.7 * - Signs with the canonical ERC-4337 UserOperation hash * - Gets gas estimates from the bundler * * @param config - UserOperation configuration * @returns UserOperation result with the userOp hash from the bundler */ export declare function buildUserOperation(config: UserOperationConfig): Promise; /** * Wait for a UserOperation to be mined and return its transaction hash. * * The UserOp was already submitted to the bundler by buildUserOperation(). * This function just waits for on-chain confirmation via the relay. * * @param serverUrl - TotalReclaw relay server URL * @param chainId - Chain ID (100 for Gnosis, 10200 for Chiado, 84532 for Base Sepolia) * @param userOpHash - UserOperation hash from buildUserOperation() * @param timeout - Timeout in ms (default: 60_000) * @returns Transaction hash of the mined UserOperation */ export declare function submitUserOperation(serverUrl: string, chainId: number, userOpHash: string, timeout?: number): Promise; /** * High-level function: build, sponsor, sign, submit a UserOperation, and * wait for on-chain confirmation. * * This is the primary entry point for writing an encrypted fact on-chain. * It combines buildUserOperation + submitUserOperation into a single call. * * @param config - Complete configuration for sending a fact on-chain * @returns Object with userOpHash and transactionHash */ export declare function sendFactOnChain(config: SendFactConfig): Promise<{ userOpHash: string; transactionHash: string; }>; //# sourceMappingURL=builder.d.ts.map