跳到正文
DEV Community· PaperPilot Tools·· 4 小時前AI 評分42

Coinbase AgentKit 預設不能支付 USDC 的 Action:48 項測試與真實 HTTP 402

A Coinbase AgentKit Action That Cannot Spend USDC by Default: 48 Tests and a Real 402

AI 導讀

開發者為 Coinbase AgentKit 建立 TypeScript ActionProvider,讓代理程式可檢視真實 HTTP 402 報價,而付款功能預設停用。48 項離線測試涵蓋報價驗證及付款防護;啟用後只可嘗試支付一次 0.01 USDC。開發者沒有執行主網付款,HTTP 200 付款回應測試資料為合成資料,亦未獲得賞金。

正文

An agent that can inspect a crypto API's payment quote and an agent that can authorize a payment are two different products. I wanted the first capability to work in Coinbase AgentKit without quietly granting the second.

I built an original TypeScript ActionProvider for Blockchain IQ's paid market brief. The first action validates a real unpaid HTTP 402. The second is disabled by default and can attempt only one authorized 0.01 Base USDC payment using a dedicated minimal-balance wallet.

Full source and 48 offline tests. This is an AI-assisted, single-owner project. No real payment was made, no customer has purchased the integration, and no bounty award has been received.

1. An HTTP 402 describes the bill, not the payment

The live endpoint at https://www.blockchainiq.co/api/x402/v1/brief returns HTTP 402 and a machine-readable PAYMENT-REQUIRED header. Its public catalogue is accessible without a wallet.

The first-party quote inspected on October 24 specified these exact terms:

Requirement Value
Chain Base mainnet / eip155:8453
Asset Native Circle USDC / 0x833589fCD6eDb6E08f4C7C32D4f71b54bdA02913
Price 10000 atomic units = 0.010000 USDC
Authorization x402 v2 exact using EIP-3009
Resource Only that precise HTTPS market-brief endpoint
Merchant The recipient on the independently inspected official quote

A developer can inspect those facts for zero USDC:

npm install --ignore-scripts --no-audit --no-fund
npm run typecheck
npm run test
npm run build
node dist/cli.js --preview

The compiled preview validates the live quote and reports spendableWalletDebited: false. It never asks for an account, signs a message or sends funds.

2. Register free and paid actions separately in AgentKit

The source uses the actual Coinbase AgentKit 0.10.4 ActionProvider, not a home-grown wrapper pretending to be AgentKit. Only Base chain 8453 is accepted. Here is an abridged excerpt:

supportsNetwork = (network: Network) =>
  network.protocolFamily === "evm" &&
  String(network.chainId) === "8453";

override getActions(walletProvider: WalletProvider) {
  if (!this.supportsNetwork(walletProvider.getNetwork())) return [];
  return [
    {
      name: "BlockchainIQActionProvider_market_brief_quote",
      schema: PreviewSchema,
      invoke: (args: unknown) =>
        this.marketBriefQuote(PreviewSchema.parse(args))
    },
    {
      name: "BlockchainIQActionProvider_market_brief_paid_once",
      schema: PaidOnceSchema,
      invoke: (args: unknown) =>
        this.marketBriefPaidOnce(PaidOnceSchema.parse(args))
    }
  ];
}

The quote action needs no signing wallet. The paid action independently checks for an explicitly supplied dedicated signer, an allowPaid opt-in and an exact Zod approval phrase. I did not install general wallet-transfer tools in the provider.

During local testing the SDK's optional action decorator triggered an unawaited analytics HTTP 400 in this environment. I used the SDK's public getActions interface instead; no vendor SDK files were modified. That observation is not a claim of a vulnerability in Coinbase AgentKit.

3. Check the quote again when the SDK is about to sign

The seller could change the terms between a preview and the paid request. A front-end warning alone would not prevent a wallet authorization from being issued for a different recipient or amount.

The official x402 client's payment policy independently enforces the same allowlist:

const client = x402Client.fromConfig({
  schemes: [{
    network: BASE_NETWORK,
    client: new ExactEvmScheme(dedicatedSigner)
  }],
  spendControls: {
    maxAmountPerPayment: 0.01,
    allowedAssets: [{
      network: BASE_NETWORK,
      asset: CIRCLE_BASE_USDC,
      maxAmountPerPayment: "10000"
    }]
  },
  policies: [(version, offers) =>
    version === 2
      ? offers.filter(offer => {
          try { assertAllowedOffer(offer); return true; }
          catch { return false; }
        })
      : []
  ]
});

That validator refuses an unfamiliar merchant, token contract, network, resource URL, amount, timeout or token-approval method. If the quote has changed, the client fails closed rather than charging whatever the service advertises.

4. HTTP 200 does not necessarily mean finalized money

Signed payment requests can be ambiguous: a merchant might settle a payment before the response times out. An agent that automatically tries again after an error can make the problem worse.

The paid path consumes its one allowed attempt before the request. The optional CLI also creates an exclusive local intent file before it can sign, so a restarted process does not silently repeat an uncertain expense.

A PAYMENT-RESPONSE header is useful evidence, but it is still service-provided evidence. My code decodes the header, verifies the Base chain and transaction-hash format, then labels the result SETTLEMENT_HEADER_RETURNED_NOT_INDEPENDENTLY_FINALIZED. A real revenue claim must additionally prove a unique, finalized Circle USDC transfer on the correct chain to the correct recipient.

5. What passed, and what is still unknown

There are 48 deterministic offline tests involving the real AgentKit action registration and invoke path: different chains, fake token/price/merchant, approval methods, malformed HTTP 402, invalid settlement proof, opt-in gates and repeated-call prevention.

Strict TypeScript compilation passed, as did the compiled free catalogue and quote preview against the real first-party site. The HTTP 402 was genuine; the HTTP 200 paid-response fixtures were synthetic and are clearly labeled.

I did not execute a mainnet paid call. The Blockchain IQ developer bounty requires a real paid x402 settlement transaction hash and independent sponsor review before any prize can be awarded. Public code and successful mock tests are not a funded contract or an earned USDC receipt.

Open source, plus optional independent code review

The Coinbase AgentKit source and my separate LangChain tool are freely inspectable. Nothing here requires buying my code.

If you maintain a different, buyer-controlled x402 integration, PaperPilot Tools also offers a separate optional 5 native Base USDC fixed-scope read-only QA review. It covers the same kind of payment quoting, recipient and duplicate-charge boundaries and returns an individual written report. The 5-USDC inquiry form is free and does not place an order, charge a wallet or request secret keys. Actual paid work requires a separate agreed scope and verified independent buyer payment.

Disclosure: Original code and this article were produced with substantial AI assistance under one human owner. No sponsorship, customer purchase, token transfer or bounty award was received for this post.

來源:DEV Community · dev.to