Skip to content

fluidbase9/fadp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FADP — Fluid Agentic DeFi Protocol

The open HTTP payment protocol for AI agents.

Gate any API endpoint behind a crypto micropayment. AI agents pay automatically — no wallets to manage, no API keys to share, no invoices.

npm version License: MIT


What is FADP?

FADP (Fluid Agentic DeFi Protocol) is an open HTTP payment protocol built on top of the standard 402 Payment Required status code. Any server can gate any endpoint. Any AI agent with a Fluid Wallet agent key pays automatically and gets access.

Agent hits gated endpoint
        ↓
Server returns 402 + X-FADP-Required: { amount, token, chain, payTo, nonce }
        ↓
Agent pays on-chain via Fluid Wallet (fwag_ key)
        ↓
Agent retries with X-FADP-Proof: { txHash, nonce, timestamp }
        ↓
Server verifies payment → unlocks resource ✅

vs x402

Feature x402 (Coinbase) FADP (Fluid)
Tokens USDC only ETH, USDC, USDT, any ERC-20
Chains Base only Base, Ethereum, Solana, Injective
Agent identity Raw wallet address Email + scoped agent key
Spend limits None Per-tx + daily cap built in
Approval flow None Owner email approval for large amounts
Agent setup Wallet + funds required Just a fwag_ key
Replay protection Signature-based Nonce-based
Open spec Yes Yes

Installation

npm install fluid-fadp

Server — Gate Any Endpoint

import express from 'express';
import { fadpGate } from 'fadp';

const app = express();

// Gate a premium endpoint — agents pay 0.01 USDC per request
app.use('/api/premium-data', fadpGate({
  amount: '0.01',
  token: 'USDC',
  chain: 'base',
  payTo: process.env.MY_WALLET_ADDRESS!,   // your Fluid Wallet address
  description: 'Premium market data API',
}));

app.get('/api/premium-data', (req, res) => {
  res.json({ data: 'secret alpha', paidBy: req.fadpPayment });
});

What the agent sees when not paying

HTTP 402
X-FADP-Required: {
  "version": "1.0",
  "amount": "0.01",
  "token": "USDC",
  "chain": "base",
  "payTo": "0xYourWalletAddress",
  "description": "Premium market data API",
  "nonce": "a3f8c2d1e4b5...",
  "expires": 1745000300,
  "verifyUrl": "https://fluidnative.com/v1/fadp/verify"
}

Client — Auto-Pay in Agents

import { fadpFetch } from 'fadp';

// Replace your normal fetch with fadpFetch
const fetch = fadpFetch({
  agentKey: process.env.FLUID_AGENT_KEY!,   // fwag_...
  maxAutoPayUsd: 5,                           // safety limit
});

// This automatically pays if the endpoint returns 402 FADP
const res = await fetch('https://anyserver.com/api/premium-data');
const data = await res.json();
// data = { data: 'secret alpha', ... }

With OpenAI Agents / LangChain

import { fadpFetch } from 'fadp';
import { FluidAgent } from 'fluid-wallet-agentkit';

const agent = new FluidAgent({ apiKey: process.env.FLUID_AGENT_KEY! });
const fetch = fadpFetch({ agentKey: process.env.FLUID_AGENT_KEY! });

// Now your agent can access any FADP-gated API on the internet
const res = await fetch('https://some-paid-api.com/data');

Next.js Middleware

// middleware.ts
import { fadpGate } from 'fadp';
import { NextRequest, NextResponse } from 'next/server';

export function middleware(req: NextRequest) {
  if (req.nextUrl.pathname.startsWith('/api/premium')) {
    // Manual FADP check for Next.js edge
    const proof = req.headers.get('x-fadp-proof');
    if (!proof) {
      return NextResponse.json(
        { error: 'Payment required', protocol: 'FADP/1.0' },
        {
          status: 402,
          headers: {
            'X-FADP-Required': JSON.stringify({
              version: '1.0',
              amount: '0.01',
              token: 'USDC',
              chain: 'base',
              payTo: process.env.MY_WALLET_ADDRESS!,
              nonce: crypto.randomUUID(),
              expires: Math.floor(Date.now() / 1000) + 300,
              verifyUrl: 'https://fluidnative.com/v1/fadp/verify',
            }),
          },
        }
      );
    }
  }
  return NextResponse.next();
}

Protocol Specification

Request Headers

Header Direction Description
X-FADP-Required Server → Agent JSON payment challenge
X-FADP-Proof Agent → Server JSON payment proof

X-FADP-Required Schema

{
  version: "1.0";
  amount: string;       // e.g. "0.01"
  token: string;        // "USDC" | "ETH" | "USDT"
  chain: string;        // "base" | "ethereum" | "solana"
  payTo: string;        // wallet address
  description?: string; // shown to agent
  nonce: string;        // one-time use, prevents replay
  expires: number;      // unix timestamp
  verifyUrl?: string;   // payment verifier endpoint
}

X-FADP-Proof Schema

{
  txHash: string;          // on-chain transaction hash
  nonce: string;           // must match the challenge nonce
  timestamp: number;       // unix timestamp of payment
  agentKeyPrefix?: string; // first 12 chars of fwag_ key (for identification)
}

Verification Endpoint

POST https://fluidnative.com/v1/fadp/verify

{
  "txHash": "0xabc...",
  "payTo": "0xServerWallet",
  "amount": "0.01",
  "token": "USDC",
  "chain": "base",
  "nonce": "a3f8c2d1..."
}

Response:

{
  "verified": true,
  "txHash": "0xabc...",
  "amount": "0.01",
  "token": "USDC",
  "chain": "base",
  "from": "0xAgentWallet",
  "to": "0xServerWallet"
}

How to Get an Agent Key

  1. Register at fluidnative.com
  2. Go to fluidnative.com/agentic-keys
  3. Create a key with pay scope
  4. Set FLUID_AGENT_KEY=fwag_... in your agent's environment

Use Cases

  • Data APIs — charge per query (market data, analytics, ML inference)
  • Compute APIs — pay per inference, rendering, or processing job
  • Agent-to-agent payments — agents paying other agents for services
  • Metered APIs — rate limiting by payment instead of API keys
  • Content paywalls — premium content unlocked by micropayment

Links


License

MIT © Fluid Wallet

About

Fluid Agentic DeFi Protocol (FADP) — Open HTTP payment protocol for AI agents. Competing open standard to x402.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors