For agents
Set up an agent that pays its own way
12 Pipe services take payment by the request: no account, no API key, no SOL. Your agent needs a wallet with USDC on Solana and any standard x402 client.
Paying by the request is switched off right now, so the check and the paid request below answer 503. A key from a plan reaches every service meanwhile.
Six steps
Make a wallet for the agent
Give the agent a wallet of its own and keep in it only what it may spend. Any Solana keypair file works; this makes a new one.
solana-keygen new --no-bip39-passphrase --outfile agent-wallet.json solana-keygen pubkey agent-wallet.jsonSend it USDC on Solana
Send USDC to the address the second command printed. A dollar pays for hundreds of requests. The wallet needs no SOL: Pipe pays the network fee for every payment.
Get the pay script
One file, pay.mjs, on the standard x402 packages. It pays Pipe’s wallet and nobody else, shows the price, and asks before it pays. It needs Node.js 20 or newer.
mkdir pipe-market && cd pipe-market && npm init -y npm install @x402/core@2 @x402/svm@2 @solana/kit@5 curl -fsSO https://pipe.network/market/pay.mjs export PIPE_MARKET_KEYPAIR="$PWD/../agent-wallet.json"Check the wallet, without paying
The gateway verifies a payment the wallet signs and never sends it.
Readymeans the wallet can pay; anything else says what is missing.node pay.mjs --checkMake a first paid request
$0.001525 for one JSON-RPC call. The script prints the price and waits for a yes; the answer comes back with the transaction that paid for it.
node pay.mjs \ "https://pipe.network/api/market/v1/call/rpc" \ '{"jsonrpc":"2.0","id":1,"method":"getSlot"}'Hand it to your agent
Paste this into your agent’s chat. The skill tells it how to find a service, read its price and pay only after you approve the spend. An agent that has your approval passes
--yes.Use the Pipe Market skill: https://pipe.network/market/SKILL.md Pay with: node pay.mjs <payUrl> ['<json body>'] in ./pipe-market. Ask me before spending more than $1 in total.
Or use your own x402 client
Standard x402, nothing of Pipe’s
The gateway speaks x402 version 2 with the exact scheme on Solana. A client that pays any x402 service pays this one. With the packages above:
import { readFileSync } from 'node:fs';
import { createKeyPairSignerFromBytes } from '@solana/kit';
import { x402Client, x402HTTPClient } from '@x402/core/client';
import { ExactSvmScheme } from '@x402/svm/exact/client';
const wallet = await createKeyPairSignerFromBytes(
Uint8Array.from(JSON.parse(readFileSync(process.env.PIPE_MARKET_KEYPAIR, 'utf8'))),
);
const http = new x402HTTPClient(
x402Client.fromConfig({
schemes: [{ network: 'solana:*', client: new ExactSvmScheme(wallet) }],
}),
);
const url = 'https://pipe.network/api/market/v1/call/rpc';
const request = {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: '{"jsonrpc":"2.0","id":1,"method":"getSlot"}',
};
// 1. Ask. The answer is 402 and states the price.
const asked = await fetch(url, request);
const required = http.getPaymentRequiredResponse(
(name) => asked.headers.get(name),
await asked.json(),
);
// 2. Check required.accepts[0] (network, asset, payTo, amount) and get
// approval for the spend. Then sign, and ask again with the payment.
const payment = await http.createPaymentPayload(required);
const answer = await fetch(url, {
...request,
headers: { ...request.headers, ...http.encodePaymentSignatureHeader(payment) },
});
console.log(answer.status, await answer.json());What you are charged
- The price in the
402answer, once, for the one request it answers. It includes $0.0015 for settling the payment on chain. - A request that reads is charged only when the service answers it. If the service fails, nothing is taken.
- A transaction send is charged before it is sent, since a sent transaction cannot be taken back.
- A payment is good for one request. Sent again, it is refused, and a refused payment never reaches the chain.
- One JSON-RPC call a request. Batches, streams and methods that keep state for their caller need a key from a plan.
Every endpoint’s address on the gateway is its payUrl in the catalogue: https://pipe.network/api/market/v1/call and the service’s own path.
The gateway’s terms
Check them before signing
Pipe takes each payment itself; no other company handles it. An agent should pay only on this network, in this currency, to this wallet, and refuse a 402 answer that names another.
- /api/market/v1/x402these terms as JSON, with what the gateway has sold
- /api/market/v1/x402/resourcesevery route sold, as an x402 resource list
- /.well-known/x402the same list, where x402 crawlers look
- /api/market/v1/x402/checkverifies a payment and never sends it
- Network
- Solana mainnet
solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp - Currency
- USDC
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v - Pay to
5YzJQX2fAFjPPERodrCADhaD2yjYnERw2Jzn1T6CTCLD- Settlement fee
- $0.0015 a request, included in the price
- Network fee
- Paid by Pipe
- Headers
PAYMENT-REQUIRED,PAYMENT-SIGNATURE,PAYMENT-RESPONSE