Intented docs

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 intented

Make 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 in

The 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);
OptionMeaning
walletthe agent's wallet. Its key must have been saved by init
tothe NEAR account to pay
amountin whole tokens, such as "0.001". Converted exactly to the token's decimals, with no floating point
tokenthe token contract. wNEAR (wrap.testnet) by default. Only tokens the firewall knows: wNEAR, USDC (3e2210e1…b8af) and USDC.e (usdc.fakes.testnet)
contextwhat your agent read that asked for this payment, verbatim. The judge reads it as data
apiUrl, rpcUrl, homeoverride the defaults for this call
onStepcalled as each step happens: proposed, verdict, executed, reported

Outcomes

outcomeWhat happened
paidthe model signed ALLOW and the wallet paid. execute_tx is the transaction
deniedthe model signed DENY and the wallet refused on-chain. execute_tx is the refusal; nothing moved
failedthe verdict was ALLOW but the wallet refused, for example over a cap or frozen. error says why
no verdictthe 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

VariableDefault
INTENTED_API_URLhttps://hack.furqaannabi.com, the hosted testnet API
INTENTED_WEB_URLhttps://intented-near.vercel.app, the web app, for the Create link
INTENTED_HOME~/.intented, where keys are kept
NEAR_RPC_URLhttps://test.rpc.fastnear.com

On this page