Pay from your agent's code
The intented library: init and pay, in TypeScript or JavaScript.
The intented package is a library as well as a CLI. It runs on Node 22.22 or later and pays on NEAR testnet.
npm install intentedMake the agent's key
import { init } from "intented";
const { walletId, publicKey, link, created } = init({ name: "my-agent" });
// walletId: "my-agent.intented.testnet"
// link: the Create page, with the name and publicKey filled inThe private key is written to ~/.intented/testnet/, readable by this user only. If a key is already saved for that name, init returns it unchanged with created: false. Open link once to create the wallet; see the quickstart.
Pay
import { pay } from "intented";
const r = await pay({
wallet: "my-agent.intented.testnet",
to: "intented-vendor.testnet",
amount: "0.001",
token: "wrap.testnet",
context: paywallResponseText,
onStep: (s) => console.log(s.step),
});
if (r.outcome === "paid") console.log("paid:", r.execute_tx);
else if (r.outcome === "denied") console.log("refused:", r.reason);
else console.log("not paid:", r.error);| Option | Meaning |
|---|---|
wallet | the agent's wallet. Its key must have been saved by init |
to | the NEAR account to pay |
amount | in whole tokens, such as "0.001". Converted exactly to the token's decimals, with no floating point |
token | the token contract. wNEAR (wrap.testnet) by default. Only tokens the firewall knows: wNEAR, USDC (3e2210e1…b8af) and USDC.e (usdc.fakes.testnet) |
context | what your agent read that asked for this payment, verbatim. The judge reads it as data |
apiUrl, rpcUrl, home | override the defaults for this call |
onStep | called as each step happens: proposed, verdict, executed, reported |
Outcomes
outcome | What happened |
|---|---|
paid | the model signed ALLOW and the wallet paid. execute_tx is the transaction |
denied | the model signed DENY and the wallet refused on-chain. execute_tx is the refusal; nothing moved |
failed | the verdict was ALLOW but the wallet refused, for example over a cap or frozen. error says why |
no verdict | the API gave no verdict, so nothing was executed. error says why |
After a denied, don't retry or reword the payment: the rules said no.
Pass the context as it is
Pass exactly what the agent read, such as the whole HTTP 402 response body, not a summary. The judge is told to treat it as untrusted data. If your agent leaves out the injected text, the judge still checks the payee, token and amount against the rules, and the wallet's caps still hold, but the receipt shows less of why the agent tried to pay.
Settings
| Variable | Default |
|---|---|
INTENTED_API_URL | https://hack.furqaannabi.com, the hosted testnet API |
INTENTED_WEB_URL | https://intented-near.vercel.app, the web app, for the Create link |
INTENTED_HOME | ~/.intented, where keys are kept |
NEAR_RPC_URL | https://test.rpc.fastnear.com |