Documentation
For buyers & agents
Buy capacity in advance, pay for requests with a portion through x402, resell what you do not use, and know what happens at expiry.
Buy
Portions are sold by the PortionMarket in USDC on Base.
- Pick a series: endpoint, model, unit, expiry and price. Check the provider's bond and track record before the discount.
- Call
buy(seriesId, units, maxCost, to).maxCostprotects you in a Dutch auction if the price moves between signing and inclusion. - The units arrive in
to. The provider is paid at the same time, minus the 0.75 % fee.
Portions are ERC-1155 tokens. They sit in any wallet that supports ERC-1155, including smart accounts used by agents.
Consume through x402
x402 turns HTTP 402 Payment Required into a payment handshake. PORTION adds the portion scheme: instead of paying USDC per request, you authorise the provider to burn units of a portion you hold.
A first request without payment returns the requirements:
POST /v1/chat/completions HTTP/1.1
Host: x402.llama70b.example
Content-Type: application/json
{"model":"llama-3.3-70b-instruct","messages":[{"role":"user","content":"Summarise this contract."}]}HTTP/1.1 402 Payment Required
Content-Type: application/json
{"x402Version":1,"accepts":[{"scheme":"portion","network":"base","seriesId":"42","redeemer":"0x…"}]}You sign a redemption with EIP-712 (holder, series, maxUnits, requestId, deadline, nonce) and retry with it in the X-PAYMENT header:
POST /v1/chat/completions HTTP/1.1
Host: x402.llama70b.example
Content-Type: application/json
X-PAYMENT: eyJzY2hlbWUiOiJwb3J0aW9uIiwicGF5bG9hZCI6eyJyZWRlbXB0aW9uIjp7ImhvbGRlciI6IjB4Li4uIiwic2VyaWVzSWQiOiI0MiIsIm1heFVuaXRzIjoiMjAiLCJyZXF1ZXN0SWQiOiIweC4uLiIsImRlYWRsaW5lIjoiMTc5MDAwMDAwMCIsIm5vbmNlIjoiNyJ9LCJzaWduYXR1cmUiOiIweC4uLiJ9fQ==
{"model":"llama-3.3-70b-instruct","messages":[{"role":"user","content":"Summarise this contract."}]}The provider verifies the redemption, serves the request and burns the units used, never more than maxUnits. The response carries the burn in X-PAYMENT-RESPONSE.
import { keccak256, toHex } from "viem";
import { signTypedData } from "viem/actions";
const redemption = {
holder: account.address,
seriesId: 42n,
maxUnits: 20_000n, // ceiling for this request, in the series' on-chain base unit
requestId: keccak256(toHex(crypto.randomUUID())),
deadline: BigInt(Math.floor(Date.now() / 1000) + 300), // valid for 5 minutes
nonce: 7n,
};
const signature = await signTypedData(wallet, {
domain: { name: "PORTION Redeemer", version: "1", chainId: 8453, verifyingContract: REDEEMER_ADDRESS },
types: {
Redemption: [
{ name: "holder", type: "address" },
{ name: "seriesId", type: "uint256" },
{ name: "maxUnits", type: "uint256" },
{ name: "requestId", type: "bytes32" },
{ name: "deadline", type: "uint64" },
{ name: "nonce", type: "uint256" },
],
},
primaryType: "Redemption",
message: redemption,
});
const payment = btoa(
JSON.stringify({ scheme: "portion", payload: { redemption, signature } }, (_, v) => (typeof v === "bigint" ? v.toString() : v)),
);Resell
If you will not use everything, sell the remainder on the series' Uniswap v4 pool against USDC. The price is set by the pool, not by PORTION. It reflects the discount to spot, the time left before expiry and the provider's standing. The protocol takes 0.75 % on the USDC side. See Secondary market.
Expiry
After expiry, units cannot be redeemed or traded, and they are not refunded. Plan consumption against the expiry date, and sell early if you will not reach it: a portion near expiry trades at a deeper discount.
If the provider fails
If the endpoint does not deliver what it sold, watchers attest and a 24-hour dispute window opens. Trading of the series is paused. If the series is slashed, you are refunded in USDC for the units you still hold, at the series' average primary price, up to what the bond covers. Refunds are claimed from the Slasher. Units already burned are not refunded.
Agents and CLIs
The flow is designed for software, not for a checkout page.
- Budget once, spend per call. An agent holds a portion and signs redemptions per request. No card, no top-ups, no per-request USDC transfer.
- Wrap it in the HTTP client. Any x402-aware client can add the
portionscheme: on a 402 response that accepts it, sign a redemption and retry. Agent CLIs that already speak x402 need one handler, not a new integration. - Hold redemptions to small scopes. Use short deadlines, per-request
maxUnitsand a session key with a spending cap. - Rebalance on-chain. An agent can buy a new series when its balance runs low, or sell a series it no longer needs, from the same wallet.