# Fundline ## Run a workflow now (one command) curl -O https://fundline.xyz/fundline-agent-gateway.js && npm i @circle-fin/x402-batching FUNDLINE_PRIVATE_KEY= node fundline-agent-gateway.js normal "" Get from GET https://fundline.xyz/api/workflows. This pays per run in USDC from your own wallet (gas-free) and prints the output. No sign-in, no account, no API key. Everything below is optional detail. Fundline runs AI workflows on demand and settles payment in USDC on the Arc blockchain. An AI agent can discover workflows and run them, paying per run from its own wallet. There is NO sign-in, NO account, and NO API key required. Identity is simply the wallet you pay from. A funded Arc USDC wallet is all you need. (An optional API key only raises per-key rate limits; it is not for auth.) ## Turnkey clients (details) Recommended: fundline-agent-gateway.js (the one-command block above) - Circle Gateway, gas-free. First time only, deposit once: FUNDLINE_PRIVATE_KEY=0x... GATEWAY_DEPOSIT=1 node fundline-agent-gateway.js. After that, runs need no deposit and no gas. Alternative without the Circle SDK: fundline-agent.js (x402, needs ethers). It sends one on-chain tx per run. Follow the Arc RPC fallback policy below or prefer the Gateway client. Your key never leaves your machine; use a dedicated agent wallet with a small balance. ## The whole flow in 3 calls (if you build it yourself) 1. GET https://fundline.xyz/api/workflows -> pick a slug and a tier. 2. POST https://fundline.xyz/api/workflows//run {tier, prompt} -> HTTP 402 + a price quote. 3. Pay, then repeat step 2 with the payment header -> HTTP 200 + the workflow output. The 402 body includes a howToPay field spelling out the exact header to send back. ## Tiers Every workflow has tiers: normal, plus, pro (higher tier = stronger model, higher price). Default is normal. There is no "standard" tier. Exact per-tier prices are in each workflow's tiers object from GET /api/workflows. ## Discover workflows GET https://fundline.xyz/api/workflows (all runnable workflows + USDC price) GET https://fundline.xyz/api/workflows?q=research (keyword search on slug/name) ## Model Context Protocol (recommended for agents) MCP endpoint (Streamable HTTP): POST https://fundline.xyz/mcp Tools: list_workflows({query}), run_workflow({slug,tier,prompt,payment}), get_run({jobId,recoveryToken}), list_runs({wallet,signature,issuedAt}). Optional header: Authorization: Bearer (not required for x402). Auto-discovery: https://fundline.xyz/.well-known/mcp.json declares this MCP server so an agent given only the domain can connect without manual setup. ## Durable MCP run flow (recommended) 1. Call list_workflows and choose a valid slug and tier. 2. Call run_workflow without payment and set paymentMode to escrow. Save jobId, runId, and recoveryToken BEFORE sending USDC. The token authorizes result access; keep it private. 3. Verify chainId 5042002, canonical USDC 0x3600000000000000000000000000000000000000, the escrow address, and the exact six-decimal amount. Approve only that amount, then fund runId. 4. Call run_workflow with payment.jobId, payment.runId, and payment.recoveryToken. 5. Poll get_run with the same credentials. Honor retryAfterSeconds until succeeded, refunded, or failed. 6. On timeout or disconnect, resume get_run. Never create and pay for a replacement job. Successful results remain retrievable for seven days by default. ## Arc RPC fallback for agent wallets Verify every RPC returns chainId 5042002 (0x4cef52) before signing. Try in order: 1. https://rpc.drpc.testnet.arc.network 2. https://rpc.blockdaemon.testnet.arc.network 3. https://rpc.quicknode.testnet.arc.network 4. https://rpc.testnet.arc.network Rotate only for connection timeout, HTTP 429, HTTP 5xx, or JSON-RPC -32011. Do not rotate and blindly retry contract reverts, insufficient funds, invalid input, bad signatures, or wrong-chain responses. USDC contract amounts use six decimals; native gas uses 18. For eth_sendRawTransaction, sign once and retain its hash. After an ambiguous response, query eth_getTransactionByHash and eth_getTransactionReceipt on another RPC before rebroadcasting the same signed raw transaction. Never create a second payment with a new nonce. ## Pay per run with x402 (no account) 1. POST https://fundline.xyz/api/workflows//run with JSON {tier, prompt} and header Accept: application/json. With no payment you get HTTP 402 and a quote: { accepts: [ { maxAmountRequired, payTo, asset (USDC), network } ] }. 2. Transfer exactly maxAmountRequired USDC (6 decimals) to payTo from your wallet on Arc (chainId 5042002, USDC 0x3600000000000000000000000000000000000000). 3. Retry the same request with header X-PAYMENT set to base64 of {"payerWallet":"0xYou","txHash":"0xYourTransfer"}. You get the workflow output. A failed run is refunded to the payer. Each payment settles one run. Legacy direct x402: obtain an HTTP 402 challenge from the workflow /run endpoint, pay it, then call MCP run_workflow with payment.payerWallet and payment.txHash. New MCP x402 clients should request paymentMode x402 first so they receive durable job credentials before paying. Escrow remains recommended because its refund behavior is contract-backed. ## Alternative: escrow (contract-guaranteed refund) POST https://fundline.xyz/api/workflows//quote -> {runId, amount, escrowAddress}. Fund the escrow (approve USDC, then fund(runId, amount)), then POST .../run with {runId, tier, prompt}. ## Run history Each paid run also returns priceUsdc, releaseTx and explorerUrl (Arcscan link). To list your past runs: GET https://fundline.xyz/api/workflows/runs signed with your wallet (headers x-fundline-wallet, x-fundline-signature, x-fundline-issued-at). It returns runs recorded under that wallet. All runs are also public on chain under your wallet. ## Docs https://fundline.xyz/docs (see the Agent API section for full details and examples).