Skip to content
B3PayPublic

About

Candid interfaces as a canonical, validated Contract graph: the Rust crate meant, and the @meantjs TypeScript schema runtime and generator.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Meant

What you meant is what runs.
The meaning layer for contract calls and signing requests, EVM first: what each value means,
what each call or signature grants, and what an AI agent's key may sign.

Docs · Quickstart · Packages · Status · Changelog


An x402 payment asks a wallet to sign value: 25000000. The EIP-712 request does not say that USDC counts in units of 10-6, so that is 25 USDC, nor that the signature pays to once and whoever holds it can submit it. A wallet shows the raw numbers, and an AI agent's key signs whatever it is handed. A Candid interface has the same gap: amount : nat does not say that 1 ICP is 108 base units.

A profile bound to a contract's interface writes the meaning down once, and from it come:

  • A guard in front of an AI agent's EVM signer. The owner confirms standing terms once, on the wallet's own screen: the chain, the tokens, who may be paid, the most per request, a budget per hour or day, and an end. The agent gets a viem account that signs only EIP-712 requests that fit, and refuses the rest before signing, each with a code and a reason. Profiles for x402, Permit2, EIP-2612, DAI's permit and USDC ship with it.
  • Consent text. For an EIP-712 signing request, matched by its type hash; experimental for EVM calls and ERC-7730 clear-signing files; ICRC-21 messages for any method on the Internet Computer.
  • Agent tools (Internet Computer). Amounts in human units, converted exactly, a preview the person confirms before every send, retries that cannot pay twice, and a class for every result.
  • Display and input formatting for amounts, times, durations, accounts, subaccounts and bytes, by one rule that refuses excess precision rather than rounding it.

How it works

Step What happens
1. Read An ABI and its EIP-712 types, or a .did, become a validated graph with an interface_id.
2. Describe A profile bound to that id says what each value means and what each call or signature grants.
3. Confirm The owner confirms the terms once: for one task, or standing terms for an agent that pays all day. The model never does.
4. Guard The key signs only a request that fits those terms; consent text shows what it does.

The problem, and what the guard does

An agent that holds a key signs what it is handed. With x402, the API names the price and the payee in its 402 answer, and the agent's client signs it: x402's own client caps a payment at $1 by default, and names no payee and no budget. A prompt injection, a bad tool result or a hostile API can ask for more, or for an unlimited token allowance, or for a "log in" message.

Meant's guard sits between the agent and the key. It reads each EIP-712 request with a profile, works out what the signature grants (which token, how much, to whom, until when), and signs only when that fits the terms the owner confirmed. It runs before signing, so nothing a refused request asked for ever exists.

Quick start (EVM, 30 seconds)

npm install --save-exact @meantjs/profile@0.10.0 @meantjs/consent@0.10.0 viem
import { privateKeyToAccount } from "viem/accounts";
import { createSchemaValidator, validateProfile } from "@meantjs/profile";
import { guardAccount } from "@meantjs/consent/guard";
import { confirmPolicy, policyText, readPolicy } from "@meantjs/consent/policy";

// The profiles the guard reads requests with: USDC's own messages (x402's default) and x402's Permit2 payments.
const validateSchema = await createSchemaValidator();
const forms = await Promise.all(["usdc-domain-usdc", "permit2", "x402-exact-permit2"].map(async (name) => {
  const { default: pack } = await import(`@meantjs/profile/packs/${name}.profile.json`, { with: { type: "json" } });
  return (await validateProfile(pack, { validateSchema, resolved: true })).resolved;
}));

const USDC = "0x036CbD53842c5426634e7929541eC2318f3dCF7e"; // Base Sepolia
const wallet = { tokens: { USDC: { address: USDC, decimals: 6 } }, apps: { "Weather API": "0x209693Bc6afc0C5328bA36FaF03C514EF312287C" } };

// The owner confirms standing terms once, on the wallet's own screen. The model never does.
const policy = confirmPolicy(readPolicy({
  chain_id: 84532,
  tokens: { USDC: { max_per_request: "0.05", budget: "0.20", per: "1 day" } },
  pay_to: ["Weather API"],
  expires_by: "30 days",
}, { ...wallet, now: BigInt(Date.now()) * 1_000_000n }));
console.log(policyText(policy));

// The agent gets this account instead of its key: a viem LocalAccount, and a signer for x402's client.
const account = guardAccount(privateKeyToAccount(process.env.AGENT_PRIVATE_KEY), { policy, wallet, forms });

Hand account to x402's client (new ExactEvmScheme(account) from @x402/evm) or to a viem wallet client. A request that does not fit is refused before signing:

// An API's 402 answer asks for 25 USDC instead of 0.01 (x402's EIP-3009 payment on Base Sepolia).
await account.signTypedData({
  types: { TransferWithAuthorization: [
    { name: "from", type: "address" }, { name: "to", type: "address" }, { name: "value", type: "uint256" },
    { name: "validAfter", type: "uint256" }, { name: "validBefore", type: "uint256" }, { name: "nonce", type: "bytes32" },
  ] },
  primaryType: "TransferWithAuthorization",
  domain: { name: "USDC", version: "2", chainId: 84532, verifyingContract: USDC },
  message: {
    from: account.address, to: "0x209693Bc6afc0C5328bA36FaF03C514EF312287C", value: 25000000n,
    validAfter: 0n, validBefore: BigInt(Math.floor(Date.now() / 1000) + 600),
    nonce: "0xf3746613c2d920b5fdabc0856f2aeb2d4f88ee6037b8cc5d04a71a4462f13480",
  },
}).catch((e) => console.log(e.code, e.violations));
// E_GUARD_REFUSED [
//   { code: 'OVER_REQUEST_CAP', message: 'the request allows 25 USDC, the standing terms allow at most 0.05 USDC a request' },
//   { code: 'OVER_BUDGET', message: 'the request allows 25 USDC, and 0 USDC was signed in the last 1 day; the standing terms allow at most 0.2 USDC in any 1 day' }
// ]

The codes are WRONG_CHAIN, UNKNOWN_REQUEST, AMBIGUOUS_REQUEST, NO_GRANT, WRONG_TOKEN, WRONG_PAYEE, WRONG_SPENDER, UNLIMITED, OVER_REQUEST_CAP, OVER_BUDGET, POLICY_EXPIRED, OUTLIVES_POLICY and NOT_TYPED_DATA (signMessage, signTransaction and signAuthorization are withheld). The consent package's README has the details, the ledger that keeps a budget across restarts, and termsGate for terms that cover one request.

An agent paying an x402 API on Base

profile/examples/x402-base-sepolia/ runs x402's own client and server (2.33.0) with the agent's key behind the guard:

cd profile/examples/x402-base-sepolia && npm ci
npm run demo     # offline, no funds: the bare key pays 3 of 3; behind the guard 20 paid and 6 refused
npm run live     # with a funded Base Sepolia test key in .env: settles the payment that fits

On 2026-12-04 the live run settled /weather, 0.01 USDC, on Base Sepolia in 0x064d3888…38d7cc1 (block 67416955), and refused a 0.10 USDC route (OVER_REQUEST_CAP) and a route that paid another address (WRONG_PAYEE) before signing.

What the guard prevents: a payment over the per-request cap or the budget, to a payee or spender the owner did not name, in another token or on another chain, an unlimited allowance, a permission that outlives the terms, a request no profile reads (a look-alike contract, an unknown primaryType), and any non-EIP-712 signature.

What it does not prevent: the guard runs in the agent's process, so it does not stop code that can read the key itself; keep the key in a separate signer process when that matters. A payment that fits the terms is paid even if the API then serves nothing useful. A budget counts what was signed, at the most each request can move, whether or not it settled. Several processes that share a budget need a ledger whose lock holds across them (a database transaction); the package ships one in memory, and the example a file.

Other quick starts

Values. Read and show values exactly:

npm install --save-exact @meantjs/format
import { parseAmount } from "@meantjs/format";

parseAmount("1.5 ICP", { decimals: 8, symbol: "ICP" }); // "150000000"
parseAmount("1.123456789", { decimals: 8 }); // throws E_EXCESS_PRECISION: never rounded

Candid in TypeScript, with no Rust toolchain:

npm install --save-exact @meantjs/schema
npm install --save-dev --save-exact @meantjs/cli   # .did to TypeScript

Candid in Rust:

[dependencies]
meant = "=0.1.1"

From a clone of this repository, the meant binary compiles a .did file and validates a Contract:

cargo run --bin meant -- compile ./service.did
cargo run --bin meant -- validate ./contract.json

Each has a quickstart on the site: EVM signing, profiles, TypeScript and Rust.

Packages

Package Version What it is
meant crates.io The Rust compiler and model: a .did file to a canonical, validated Contract graph with content-addressed identities, and the meant binary
@meantjs/schema npm Typed schemas, validation and a Candid binary codec from the same graph, with no runtime dependencies
@meantjs/cli npm The compiler and generator as WebAssembly: a .did file to a TypeScript module, with no Rust toolchain
The profile packages npm The Meant Profile spec, its standard packs, and five packages released together, @meantjs/profile, format, consent, tools and reconcile, which resolve profiles and generate consent text, a signer's guard, tools and formatting from them
meant-format crates.io The profile's amount tag in Rust, with no dependencies and no_std

The crates and the two npm families version independently.

Status

Everything here is pre-1.0. Any release before 1.0 may change the public API, the serialized shapes, the canonical bytes and every identity computed over them, so pin exact versions: meant = "=0.1.1", npm install --save-exact. The profile spec is Draft 0.2; a breaking change to anything stable within v0 is a decision row and a breaking-change note in the changelog.

  • EVM contracts: what a signer's guard uses is stable within v0 (D-065): profiles of EIP-712 messages, x402 and Permit2 included, their consent text, what a signature grants, and the terms check and guard. ABI calls, the ERC-20 pack and ERC-7730 files are experimental.
  • Internet Computer: supported. Candid interfaces, the ICRC-1 and ICRC-2 packs, ICRC-21 consent, agent tools, reconcile and PocketIC.
  • Solana: planned, not supported yet.

Renamed. The crate candid-core is now meant (use meant::…, binary meant), and the npm pair @candid-core/schema and @candid-core/cli is now @meantjs/schema and @meantjs/cli, whose command is meant. The Contract format and its candid-core: identity prefixes are unchanged. Details.

Documentation

Repository layout

src/                  the meant crate: model, validation, canonicalization, compiler, CLI
examples/             runnable Rust examples
crates/meant-ts/      the TypeScript generator; @meantjs/schema is in ts/
crates/meant-wasm/    @meantjs/cli, the compiler and generator as WebAssembly
crates/meant-format/  meant-format, the amount tag in Rust
profile/              the profile spec, packs and packages (a synced copy, see below)
website/              the source of b3pay.net/docs/meant
docs/                 design documents, ADRs, verification and release procedures
tests/, benches/      the test suites and the benchmarks
fuzz/                 the fuzz targets, a workspace of their own

Contributing

Issues and pull requests are welcome. profile/ and its two workflows are a synced copy of the profile's working repository, so a maintainer applies an accepted change there and the next sync brings it back (how that folder is made). The checks to run before a pull request are in CLAUDE.md.

License

Apache-2.0 (LICENSE). Meant is a B3Pay project.

About

Candid interfaces as a canonical, validated Contract graph: the Rust crate meant, and the @meantjs TypeScript schema runtime and generator.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages