Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

homepage zoom out cz and agent payments sdk

nirholas434af44520a6
diff --git a/agent-payments-crosschain-sdk/src/evm/EvmAgentOffline.ts b/agent-payments-crosschain-sdk/src/evm/EvmAgentOffline.ts
new file mode 100644
index 000000000..411f79991
--- /dev/null
+++ b/agent-payments-crosschain-sdk/src/evm/EvmAgentOffline.ts
@@ -0,0 +1,258 @@
+import {
+ encodeFunctionData,
+ maxUint256,
+ type Address,
+ type Hex,
+} from "viem";
+import { AGENT_PAYMENTS_ABI, ERC20_ABI } from "./abi.js";
+import { getEvmChain, NATIVE_TOKEN_ADDRESS, type EvmChainId } from "./addresses.js";
+import { getInvoiceId, buildInvoiceWindow, generateMemo } from "./invoice.js";
+import type {
+ EvmAcceptPaymentParams,
+ EvmBuybackTriggerParams,
+ EvmCreateParams,
+ EvmDistributePaymentsParams,
+ EvmTxBundle,
+ EvmUnsignedTx,
+ EvmUpdateAuthorityParams,
+ EvmUpdateBuybackBpsParams,
+ EvmWithdrawParams,
+} from "./types.js";
+
+/**
+ * EvmAgentOffline — builds unsigned EVM transactions for the Agent Payments contract.
+ * No RPC connection required. Mirrors PumpAgentOffline from the Solana SDK.
+ *
+ * Usage:
+ * const agent = new EvmAgentOffline("0xYourAgentToken", 8453);
+ * const bundle = agent.buildAcceptPaymentTx({ ... });
+ * // send bundle.approval then bundle.tx via user's wallet
+ */
+export class EvmAgentOffline {
+ readonly agentToken: Address;
+ readonly chainId: EvmChainId;
+ readonly contractAddress: Address;
+
+ constructor(agentToken: Address, chainId: EvmChainId) {
+ this.agentToken = agentToken;
+ this.chainId = chainId;
+ this.contractAddress = getEvmChain(chainId).agentPayments;
+ }
+
+ // ── Agent setup ────────────────────────────────────────────────────────────
+
+ /** Build the createAgent transaction (one-time agent registration). */
+ buildCreateAgentTx(params: EvmCreateParams): EvmUnsignedTx {
+ return {
+ to: this.contractAddress,
+ data: encodeFunctionData({
+ abi: AGENT_PAYMENTS_ABI,
+ functionName: "createAgent",
+ args: [params.agentToken, params.agentAuthority, params.buybackBps],
+ }),
+ value: 0n,
+ chainId: this.chainId,
+ };
+ }
+
+ // ── Payment acceptance ────────────────────────────────────────────────────
+
+ /**
+ * Build the acceptPayment transaction bundle.
+ * Returns an optional ERC-20 approval + the main payment tx.
+ *
+ * For native currency (ETH/BNB/AVAX), pass currencyToken as "native".
+ * The value field on the tx will be set to the payment amount.
+ */
+ buildAcceptPaymentTx(
+ params: EvmAcceptPaymentParams,
+ payer: Address
+ ): EvmTxBundle {
+ const isNative = params.currencyToken === "native";
+
+ if (isNative) {
+ return {
+ tx: {
+ to: this.contractAddress,
+ data: encodeFunctionData({
+ abi: AGENT_PAYMENTS_ABI,
+ functionName: "acceptPaymentNative",
+ args: [
+ params.agentToken,
+ params.memo,
+ params.startTime,
+ params.endTime,
+ ],
+ }),
+ value: params.amount,
+ chainId: this.chainId,
+ },
+ };
+ }
+
+ const approval: EvmUnsignedTx = {
+ to: params.currencyToken as Address,
+ data: encodeFunctionData({
+ abi: ERC20_ABI,
+ functionName: "approve",
+ args: [this.contractAddress, maxUint256],
+ }),
+ value: 0n,
+ chainId: this.chainId,
+ };
+
+ const tx: EvmUnsignedTx = {
+ to: this.contractAddress,
+ data: encodeFunctionData({
+ abi: AGENT_PAYMENTS_ABI,
+ functionName: "acceptPayment",
+ args: [
+ params.agentToken,
+ params.currencyToken as Address,
+ params.amount,
+ params.memo,
+ params.startTime,
+ params.endTime,
+ ],
+ }),
+ value: 0n,
+ chainId: this.chainId,
+ };
+
+ return { approval, tx };
+ }
+
+ /**
+ * Convenience wrapper: auto-generates memo + time window.
+ * Mirrors PumpAgentOffline.buildAcceptPaymentInstructions().
+ */
+ buildAcceptPaymentInstructions(opts: {
+ agentToken: Address;
+ currencyToken: Address | "native";
+ amount: bigint;
+ payer: Address;
+ windowSeconds?: number;
+ }): { bundle: EvmTxBundle; memo: bigint; invoiceId: Hex } {
+ const memo = generateMemo();
+ const { startTime, endTime } = buildInvoiceWindow(opts.windowSeconds);
+ const currencyAddress =
+ opts.currencyToken === "native" ? NATIVE_TOKEN_ADDRESS : opts.currencyToken;
+
+ const invoiceId = getInvoiceId(
+ opts.agentToken,
+ currencyAddress,
+ opts.amount,
+ memo,
+ startTime,
+ endTime
+ );
+
+ const bundle = this.buildAcceptPaymentTx(
+ {
+ agentToken: opts.agentToken,
+ currencyToken: opts.currencyToken,
+ amount: opts.amount,
+ memo,
+ startTime,
+ endTime,
+ },
+ opts.payer
+ );
+
+ return { bundle, memo, invoiceId };
+ }
+
+ // ── Distribution + buyback ─────────────────────────────────────────────────
+
+ /** Build the distributePayments transaction. Permissionless. */
+ buildDistributePaymentsTx(params: EvmDistributePaymentsParams): EvmUnsignedTx {
+ return {
+ to: this.contractAddress,
+ data: encodeFunctionData({
+ abi: AGENT_PAYMENTS_ABI,
+ functionName: "distributePayments",
+ args: [params.agentToken, params.currencyToken],
+ }),
+ value: 0n,
+ chainId: this.chainId,
+ };
+ }
+
+ /** Build the buybackTrigger transaction. Caller must be global buyback authority. */
+ buildBuybackTriggerTx(params: EvmBuybackTriggerParams): EvmUnsignedTx {
+ return {
+ to: this.contractAddress,
+ data: encodeFunctionData({
+ abi: AGENT_PAYMENTS_ABI,
+ functionName: "buybackTrigger",
+ args: [
+ params.agentToken,
+ params.currencyToken,
+ params.swapRouter,
+ params.swapData,
+ ],
+ }),
+ value: 0n,
+ chainId: this.chainId,
+ };
+ }
+
+ // ── Withdrawal ─────────────────────────────────────────────────────────────
+
+ /** Build the withdraw transaction. Caller must be agent authority. */
+ buildWithdrawTx(params: EvmWithdrawParams): EvmUnsignedTx {
+ return {
+ to: this.contractAddress,
+ data: encodeFunctionData({
+ abi: AGENT_PAYMENTS_ABI,
+ functionName: "withdraw",
+ args: [params.agentToken, params.currencyToken, params.receiver],
+ }),
+ value: 0n,
+ chainId: this.chainId,
+ };
+ }
+
+ // ── Config updates ─────────────────────────────────────────────────────────
+
+ buildUpdateBuybackBpsTx(params: EvmUpdateBuybackBpsParams): EvmUnsignedTx {
+ return {
+ to: this.contractAddress,
+ data: encodeFunctionData({
+ abi: AGENT_PAYMENTS_ABI,
+ functionName: "updateBuybackBps",
+ args: [params.agentToken, params.buybackBps],
+ }),
+ value: 0n,
+ chainId: this.chainId,
+ };
+ }
+
+ buildUpdateAuthorityTx(params: EvmUpdateAuthorityParams): EvmUnsignedTx {
+ return {
+ to: this.contractAddress,
+ data: encodeFunctionData({
+ abi: AGENT_PAYMENTS_ABI,
+ functionName: "updateAuthority",
+ args: [params.agentToken, params.newAuthority],
+ }),
+ value: 0n,
+ chainId: this.chainId,
+ };
+ }
+
+ // ── Helpers ────────────────────────────────────────────────────────────────
+
+ /** Compute the invoice ID for a payment without sending anything. */
+ computeInvoiceId(
+ currencyToken: Address | "native",
+ amount: bigint,
+ memo: bigint,
+ startTime: bigint,
+ endTime: bigint
+ ): Hex {
+ const currency =
+ currencyToken === "native" ? NATIVE_TOKEN_ADDRESS : currencyToken;
+ return getInvoiceId(this.agentToken, currency, amount, memo, startTime, endTime);
+ }
+}
diff --git a/agent-payments-crosschain-sdk/src/evm/abi.ts b/agent-payments-crosschain-sdk/src/evm/abi.ts
new file mode 100644
index 000000000..dad2aab74
--- /dev/null
+++ b/agent-payments-crosschain-sdk/src/evm/abi.ts
@@ -0,0 +1,283 @@
+/**
+ * ABI for the EVM Agent Payments contract.
+ * Mirrors the Solana pump_agent_payments program interface.
+ *
+ * Functions:
+ * createAgent — register an agent (mirrors agentInitialize)
+ * acceptPayment — user pays agent (mirrors agentAcceptPayment)
+ * distributePayments— split vault to buyback + withdraw (mirrors agentDistributePayments)
+ * buybackTrigger — swap + burn agent token (mirrors agentBuybackTrigger)
+ * withdraw — owner pulls from withdraw vault (mirrors agentWithdraw)
+ * updateBuybackBps — change buyback split
+ * updateAuthority — transfer agent authority
+ */
+export const AGENT_PAYMENTS_ABI = [
+ // ── Write functions ──────────────────────────────────────────────────────
+
+ {
+ name: "createAgent",
+ type: "function",
+ stateMutability: "nonpayable",
+ inputs: [
+ { name: "agentToken", type: "address" },
+ { name: "agentAuthority", type: "address" },
+ { name: "buybackBps", type: "uint16" },
+ ],
+ outputs: [],
+ },
+
+ {
+ name: "acceptPayment",
+ type: "function",
+ stateMutability: "nonpayable",
+ inputs: [
+ { name: "agentToken", type: "address" },
+ { name: "currencyToken", type: "address" },
+ { name: "amount", type: "uint256" },
+ { name: "memo", type: "uint64" },
+ { name: "startTime", type: "int64" },
+ { name: "endTime", type: "int64" },
+ ],
+ outputs: [{ name: "invoiceId", type: "bytes32" }],
+ },
+
+ {
+ name: "acceptPaymentNative",
+ type: "function",
+ stateMutability: "payable",
+ inputs: [
+ { name: "agentToken", type: "address" },
+ { name: "memo", type: "uint64" },
+ { name: "startTime", type: "int64" },
+ { name: "endTime", type: "int64" },
+ ],
+ outputs: [{ name: "invoiceId", type: "bytes32" }],
+ },
+
+ {
+ name: "distributePayments",
+ type: "function",
+ stateMutability: "nonpayable",
+ inputs: [
+ { name: "agentToken", type: "address" },
+ { name: "currencyToken", type: "address" },
+ ],
+ outputs: [],
+ },
+
+ {
+ name: "buybackTrigger",
+ type: "function",
+ stateMutability: "nonpayable",
+ inputs: [
+ { name: "agentToken", type: "address" },
+ { name: "currencyToken", type: "address" },
+ { name: "swapRouter", type: "address" },
+ { name: "swapData", type: "bytes" },
+ ],
+ outputs: [{ name: "tokensBurned", type: "uint256" }],
+ },
+
+ {
+ name: "withdraw",
+ type: "function",
+ stateMutability: "nonpayable",
+ inputs: [
+ { name: "agentToken", type: "address" },
+ { name: "currencyToken", type: "address" },
+ { name: "receiver", type: "address" },
+ ],
+ outputs: [{ name: "amount", type: "uint256" }],
+ },
+
+ {
+ name: "updateBuybackBps",
+ type: "function",
+ stateMutability: "nonpayable",
+ inputs: [
+ { name: "agentToken", type: "address" },
+ { name: "buybackBps", type: "uint16" },
+ ],
+ outputs: [],
+ },
+
+ {
+ name: "updateAuthority",
+ type: "function",
+ stateMutability: "nonpayable",
+ inputs: [
+ { name: "agentToken", type: "address" },
+ { name: "newAuthority", type: "address" },
+ ],
+ outputs: [],
+ },
+
+ // ── Read functions ───────────────────────────────────────────────────────
+
+ {
+ name: "getAgentConfig",
+ type: "function",
+ stateMutability: "view",
+ inputs: [{ name: "agentToken", type: "address" }],
+ outputs: [
+ { name: "authority", type: "address" },
+ { name: "buybackBps", type: "uint16" },
+ { name: "exists", type: "bool" },
+ ],
+ },
+
+ {
+ name: "getBalances",
+ type: "function",
+ stateMutability: "view",
+ inputs: [
+ { name: "agentToken", type: "address" },
+ { name: "currencyToken", type: "address" },
+ ],
+ outputs: [
+ { name: "paymentVault", type: "uint256" },
+ { name: "buybackVault", type: "uint256" },
+ { name: "withdrawVault", type: "uint256" },
+ ],
+ },
+
+ {
+ name: "getPaymentStats",
+ type: "function",
+ stateMutability: "view",
+ inputs: [
+ { name: "agentToken", type: "address" },
+ { name: "currencyToken", type: "address" },
+ ],
+ outputs: [
+ { name: "totalPayments", type: "uint256" },
+ { name: "totalBuybacks", type: "uint256" },
+ { name: "totalWithdrawn", type: "uint256" },
+ { name: "tokensBurned", type: "uint256" },
+ ],
+ },
+
+ {
+ name: "isInvoicePaid",
+ type: "function",
+ stateMutability: "view",
+ inputs: [{ name: "invoiceId", type: "bytes32" }],
+ outputs: [{ name: "", type: "bool" }],
+ },
+
+ // ── Events ───────────────────────────────────────────────────────────────
+
+ {
+ name: "AgentCreated",
+ type: "event",
+ inputs: [
+ { name: "agentToken", type: "address", indexed: true },
+ { name: "authority", type: "address", indexed: true },
+ { name: "buybackBps", type: "uint16", indexed: false },
+ ],
+ },
+
+ {
+ name: "PaymentAccepted",
+ type: "event",
+ inputs: [
+ { name: "agentToken", type: "address", indexed: true },
+ { name: "payer", type: "address", indexed: true },
+ { name: "currencyToken", type: "address", indexed: false },
+ { name: "amount", type: "uint256", indexed: false },
+ { name: "memo", type: "uint64", indexed: false },
+ { name: "invoiceId", type: "bytes32", indexed: false },
+ ],
+ },
+
+ {
+ name: "PaymentsDistributed",
+ type: "event",
+ inputs: [
+ { name: "agentToken", type: "address", indexed: true },
+ { name: "currencyToken", type: "address", indexed: false },
+ { name: "buybackAmount", type: "uint256", indexed: false },
+ { name: "withdrawAmount", type: "uint256", indexed: false },
+ ],
+ },
+
+ {
+ name: "BuybackTriggered",
+ type: "event",
+ inputs: [
+ { name: "agentToken", type: "address", indexed: true },
+ { name: "currencyToken", type: "address", indexed: false },
+ { name: "currencySpent", type: "uint256", indexed: false },
+ { name: "tokensBurned", type: "uint256", indexed: false },
+ ],
+ },
+
+ {
+ name: "Withdrawn",
+ type: "event",
+ inputs: [
+ { name: "agentToken", type: "address", indexed: true },
+ { name: "authority", type: "address", indexed: true },
+ { name: "currencyToken", type: "address", indexed: false },
+ { name: "amount", type: "uint256", indexed: false },
+ { name: "receiver", type: "address", indexed: false },
+ ],
+ },
+
+ {
+ name: "AuthorityUpdated",
+ type: "event",
+ inputs: [
+ { name: "agentToken", type: "address", indexed: true },
+ { name: "oldAuthority", type: "address", indexed: false },
+ { name: "newAuthority", type: "address", indexed: false },
+ ],
+ },
+
+ {
+ name: "BuybackBpsUpdated",
+ type: "event",
+ inputs: [
+ { name: "agentToken", type: "address", indexed: true },
+ { name: "oldBps", type: "uint16", indexed: false },
+ { name: "newBps", type: "uint16", indexed: false },
+ ],
+ },
+] as const;
+
+export const ERC20_ABI = [
+ {
+ name: "approve",
+ type: "function",
+ stateMutability: "nonpayable",
+ inputs: [
+ { name: "spender", type: "address" },
+ { name: "amount", type: "uint256" },
+ ],
+ outputs: [{ name: "", type: "bool" }],
+ },
+ {
+ name: "allowance",
+ type: "function",
+ stateMutability: "view",
+ inputs: [
+ { name: "owner", type: "address" },
+ { name: "spender", type: "address" },
+ ],
+ outputs: [{ name: "", type: "uint256" }],
+ },
+ {
+ name: "balanceOf",
+ type: "function",
+ stateMutability: "view",
+ inputs: [{ name: "account", type: "address" }],
+ outputs: [{ name: "", type: "uint256" }],
+ },
+ {
+ name: "decimals",
+ type: "function",
+ stateMutability: "view",
+ inputs: [],
+ outputs: [{ name: "", type: "uint8" }],
+ },
+] as const;
diff --git a/agent-payments-crosschain-sdk/src/evm/addresses.ts b/agent-payments-crosschain-sdk/src/evm/addresses.ts
new file mode 100644
index 000000000..ee2fa1b96
--- /dev/null
+++ b/agent-payments-crosschain-sdk/src/evm/addresses.ts
@@ -0,0 +1,98 @@
+import type { Address } from "viem";
+
+export type EvmChainId = 1 | 8453 | 42161 | 137 | 56 | 43114;
+
+export interface EvmChainConfig {
+ id: EvmChainId;
+ name: string;
+ rpcUrl: string;
+ blockExplorer: string;
+ nativeCurrency: { name: string; symbol: string; decimals: number };
+ /** USDC token address on this chain */
+ usdc: Address;
+ /** WETH/wrapped native address */
+ wrappedNative: Address;
+ /** Deployed AgentPayments contract — set after deployment */
+ agentPayments: Address;
+}
+
+/** Placeholder — replace with deployed contract addresses post-deployment */
+const UNDEPLOYED = "0x0000000000000000000000000000000000000000" as Address;
+
+export const EVM_CHAINS: Record<EvmChainId, EvmChainConfig> = {
+ 1: {
+ id: 1,
+ name: "Ethereum",
+ rpcUrl: "https://eth.llamarpc.com",
+ blockExplorer: "https://etherscan.io",
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
+ usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
+ wrappedNative: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
+ agentPayments: UNDEPLOYED,
+ },
+ 8453: {
+ id: 8453,
+ name: "Base",
+ rpcUrl: "https://mainnet.base.org",
+ blockExplorer: "https://basescan.org",
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
+ usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
+ wrappedNative: "0x4200000000000000000000000000000000000006",
+ agentPayments: UNDEPLOYED,
+ },
+ 42161: {
+ id: 42161,
+ name: "Arbitrum One",
+ rpcUrl: "https://arb1.arbitrum.io/rpc",
+ blockExplorer: "https://arbiscan.io",
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
+ usdc: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
+ wrappedNative: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
+ agentPayments: UNDEPLOYED,
+ },
+ 137: {
+ id: 137,
+ name: "Polygon",
+ rpcUrl: "https://polygon-rpc.com",
+ blockExplorer: "https://polygonscan.com",
+ nativeCurrency: { name: "POL", symbol: "POL", decimals: 18 },
+ usdc: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
+ wrappedNative: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
+ agentPayments: UNDEPLOYED,
+ },
+ 56: {
+ id: 56,
+ name: "BNB Smart Chain",
+ rpcUrl: "https://bsc-dataseed.binance.org",
+ blockExplorer: "https://bscscan.com",
+ nativeCurrency: { name: "BNB", symbol: "BNB", decimals: 18 },
+ usdc: "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",
+ wrappedNative: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
+ agentPayments: UNDEPLOYED,
+ },
+ 43114: {
+ id: 43114,
+ name: "Avalanche",
+ rpcUrl: "https://api.avax.network/ext/bc/C/rpc",
+ blockExplorer: "https://snowtrace.io",
+ nativeCurrency: { name: "AVAX", symbol: "AVAX", decimals: 18 },
+ usdc: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
+ wrappedNative: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
+ agentPayments: UNDEPLOYED,
+ },
+};
+
+export const SUPPORTED_CHAIN_IDS = Object.keys(EVM_CHAINS).map(Number) as EvmChainId[];
+
+export function getEvmChain(chainId: EvmChainId): EvmChainConfig {
+ const chain = EVM_CHAINS[chainId];
+ if (!chain) throw new Error(`Unsupported EVM chain: ${chainId}`);
+ return chain;
+}
+
+export function isEvmChainSupported(chainId: number): chainId is EvmChainId {
+ return chainId in EVM_CHAINS;
+}
+
+/** Native ETH/BNB/AVAX sentinel address (matches EIP-7528) */
+export const NATIVE_TOKEN_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" as Address;
diff --git a/agent-payments-crosschain-sdk/src/evm/invoice.ts b/agent-payments-crosschain-sdk/src/evm/invoice.ts
new file mode 100644
index 000000000..64f2cd069
--- /dev/null
+++ b/agent-payments-crosschain-sdk/src/evm/invoice.ts
@@ -0,0 +1,60 @@
+import { encodeAbiParameters, keccak256 } from "viem";
+import type { Address } from "viem";
+
+/**
+ * Derives a deterministic invoice ID — the EVM equivalent of the Solana InvoiceId PDA.
+ *
+ * Mirrors PDA seeds: ["invoice-id", tokenMint, currencyMint, amount, memo, startTime, endTime]
+ *
+ * On-chain the contract computes:
+ * keccak256(abi.encode(agentToken, currencyToken, amount, memo, startTime, endTime))
+ */
+export function getInvoiceId(
+ agentToken: Address,
+ currencyToken: Address,
+ amount: bigint,
+ memo: bigint,
+ startTime: bigint,
+ endTime: bigint
+): `0x${string}` {
+ return keccak256(
+ encodeAbiParameters(
+ [
+ { type: "address" },
+ { type: "address" },
+ { type: "uint256" },
+ { type: "uint64" },
+ { type: "int64" },
+ { type: "int64" },
+ ],
+ [agentToken, currencyToken, amount, memo, startTime, endTime]
+ )
+ );
+}
+
+/**
+ * Build a time-bounded invoice window matching the Solana SDK's convention.
+ * Returns startTime and endTime as unix timestamps (seconds).
+ *
+ * @param windowSeconds How long the invoice is valid (default: 5 minutes)
+ */
+export function buildInvoiceWindow(windowSeconds = 300): {
+ startTime: bigint;
+ endTime: bigint;
+} {
+ const now = BigInt(Math.floor(Date.now() / 1000));
+ return {
+ startTime: now,
+ endTime: now + BigInt(windowSeconds),
+ };
+}
+
+/**
+ * Generate a random memo ID — same helper pattern as the Solana SDK.
+ * Returns a random u64 as bigint.
+ */
+export function generateMemo(): bigint {
+ const arr = new Uint8Array(8);
+ crypto.getRandomValues(arr);
+ return arr.reduce((acc, byte) => (acc << 8n) | BigInt(byte), 0n);
+}
diff --git a/agent-payments-crosschain-sdk/src/evm/types.ts b/agent-payments-crosschain-sdk/src/evm/types.ts
new file mode 100644
index 000000000..1efc558f7
--- /dev/null
+++ b/agent-payments-crosschain-sdk/src/evm/types.ts
@@ -0,0 +1,162 @@
+import type { Address, Hash, Hex } from "viem";
+import type { EvmChainId } from "./addresses.js";
+
+/** Mirrors Solana's TokenAgentPayments account */
+export interface EvmAgentConfig {
+ agentToken: Address;
+ authority: Address;
+ buybackBps: number;
+ exists: boolean;
+}
+
+/** Mirrors Solana's AgentBalances */
+export interface EvmAgentBalances {
+ agentToken: Address;
+ currencyToken: Address;
+ paymentVault: bigint;
+ buybackVault: bigint;
+ withdrawVault: bigint;
+}
+
+/** Mirrors Solana's TokenAgentPaymentInCurrency */
+export interface EvmPaymentStats {
+ agentToken: Address;
+ currencyToken: Address;
+ totalPayments: bigint;
+ totalBuybacks: bigint;
+ totalWithdrawn: bigint;
+ tokensBurned: bigint;
+}
+
+/** Mirrors Solana's CreateParams */
+export interface EvmCreateParams {
+ agentToken: Address;
+ agentAuthority: Address;
+ buybackBps: number;
+}
+
+/** Mirrors Solana's AcceptPaymentSimpleParams */
+export interface EvmAcceptPaymentParams {
+ agentToken: Address;
+ currencyToken: Address | "native";
+ amount: bigint;
+ memo: bigint;
+ startTime: bigint;
+ endTime: bigint;
+}
+
+/** Mirrors Solana's DistributePaymentsParams */
+export interface EvmDistributePaymentsParams {
+ agentToken: Address;
+ currencyToken: Address;
+}
+
+/** Mirrors Solana's BuybackTriggerParams */
+export interface EvmBuybackTriggerParams {
+ agentToken: Address;
+ currencyToken: Address;
+ swapRouter: Address;
+ swapData: Hex;
+}
+
+/** Mirrors Solana's WithdrawParams */
+export interface EvmWithdrawParams {
+ agentToken: Address;
+ currencyToken: Address;
+ receiver: Address;
+}
+
+export interface EvmUpdateBuybackBpsParams {
+ agentToken: Address;
+ buybackBps: number;
+}
+
+export interface EvmUpdateAuthorityParams {
+ agentToken: Address;
+ newAuthority: Address;
+}
+
+/** A built unsigned EVM transaction ready for the user's wallet to sign */
+export interface EvmUnsignedTx {
+ to: Address;
+ data: Hex;
+ value: bigint;
+ chainId: EvmChainId;
+}
+
+/** An optional ERC-20 approval + main transaction pair */
+export interface EvmTxBundle {
+ /** ERC-20 approval — present when paying with an ERC-20 token */
+ approval?: EvmUnsignedTx;
+ /** The main contract call */
+ tx: EvmUnsignedTx;
+}
+
+/** Mirrors Solana's invoice validation result */
+export interface EvmInvoiceValidationResult {
+ paid: boolean;
+ invoiceId: Hash;
+ txHash?: Hash;
+ blockNumber?: bigint;
+}
+
+// ── Events (mirrors Solana event types) ─────────────────────────────────────
+
+export interface EvmAgentCreatedEvent {
+ name: "AgentCreated";
+ agentToken: Address;
+ authority: Address;
+ buybackBps: number;
+ txHash: Hash;
+ blockNumber: bigint;
+}
+
+export interface EvmPaymentAcceptedEvent {
+ name: "PaymentAccepted";
+ agentToken: Address;
+ payer: Address;
+ currencyToken: Address;
+ amount: bigint;
+ memo: bigint;
+ invoiceId: Hash;
+ txHash: Hash;
+ blockNumber: bigint;
+}
+
+export interface EvmPaymentsDistributedEvent {
+ name: "PaymentsDistributed";
+ agentToken: Address;
+ currencyToken: Address;
+ buybackAmount: bigint;
+ withdrawAmount: bigint;
+ txHash: Hash;
+ blockNumber: bigint;
+}
+
+export interface EvmBuybackTriggeredEvent {
+ name: "BuybackTriggered";
+ agentToken: Address;
+ currencyToken: Address;
+ currencySpent: bigint;
+ tokensBurned: bigint;
+ txHash: Hash;
+ blockNumber: bigint;
+}
+
+export interface EvmWithdrawnEvent {
+ name: "Withdrawn";
+ agentToken: Address;
+ authority: Address;
+ currencyToken: Address;
+ amount: bigint;
+ receiver: Address;
+ txHash: Hash;
+ blockNumber: bigint;
+}
+
+export type EvmAgentEvent =
+ | EvmAgentCreatedEvent
+ | EvmPaymentAcceptedEvent
+ | EvmPaymentsDistributedEvent
+ | EvmBuybackTriggeredEvent
+ | EvmWithdrawnEvent;
diff --git a/home.html b/home.html
index b827cfb62..dfc7b9621 100644
--- a/home.html
+++ b/home.html
@@ -859,7 +859,7 @@
scrollProgress = 0;
const BASE_THETA = -45,
BASE_PHI = 80,
- BASE_R = 14;
+ BASE_R = 20;
let curTheta = BASE_THETA,
curPhi = BASE_PHI,
curR = BASE_R;
@@ -951,6 +951,17 @@
viewer
.loadModel('/avatars/cz.glb', { autoPlay: false })
.then(async () => {
+ /* Scale up ring geometry so it fills the canvas */
+ viewer.model.traverse((node) => {
+ if (node.isMesh || node.isGroup) {
+ const n = node.name.toLowerCase();
+ if (n.includes('ring') || n.includes('circle') || n.includes('halo') || n.includes('orbit') || n.includes('arc')) {
+ node.scale.setScalar(2.5);
+ }
+ }
+ console.log('[cz node]', node.name, node.type);
+ });
+ viewer._modelFocusY = 1.1;
viewer.setOrbit(curTheta, curPhi, curR);
orbitActive = true;
/* fetch + start the falling clip before revealing — no T-pose flash */