Profiles
Quickstart: EVM signing
Put a check between an AI agent and its EVM key: the person confirms a task's terms once, and the key signs only an EIP-712 request that fits them.
An AI agent that holds an EVM key signs what it is handed. When an x402 API's answer asks for 25 USDC instead of 0.01, a bare key signs that too. This quickstart puts a Meant check between the agent and its key: the person confirms the task's terms once, on the wallet's own screen, and the wallet then signs only an EIP-712 request that a profile reads and whose grant fits those terms. You need Node 22 or later and npm. Nothing here touches a chain or holds funds: the request is x402's own EIP-3009 example on Base Sepolia, a test network.
mkdir evm-quickstart && cd evm-quickstart
npm init -y
npm install --save-exact @meantjs/profile@0.9.0 @meantjs/consent@0.9.0
@meantjs/profile ships the profiles of x402's payments, Permit2, EIP-2612, DAI's permit and USDC's
EIP-3009 messages, and resolves them. @meantjs/consent reads a signing request against a profile, writes
its consent text and says what it grants (./evm), checks that grant against terms
(./terms), and guards a signer (./guard). Set "type": "module" in
package.json and put the three blocks below in quickstart.js, in order.
Load a profile and say what the wallet knows#
import { createSchemaValidator, validateProfile } from "@meantjs/profile";
import { eip712Consent } from "@meantjs/consent/evm";
import { readTerms, termsGate } from "@meantjs/consent/terms";
import usdc from "@meantjs/profile/packs/usdc-domain-usdc.profile.json" with { type: "json" };
// USDC's EIP-3009 messages where USDC signs as "USDC", Base Sepolia among them, shipped with @meantjs/profile.
const validateSchema = await createSchemaValidator();
const result = await validateProfile(usdc, { validateSchema, resolved: true });
if (!result.resolved) throw new Error("the profile does not validate");
const resolved = result.resolved;
// What the wallet knows: its tokens, the apps the person named, its clock.
const USDC = "0x036CbD53842c5426634e7929541eC2318f3dCF7e";
const wallet = {
tokens: { USDC: { address: USDC, decimals: 6 } },
apps: { "Weather API": "0x209693Bc6afc0C5328bA36FaF03C514EF312287C" },
now: BigInt(Date.parse("2025-02-27T16:00:00Z")) * 1_000_000n, // nanoseconds
};The profile is bound to USDC's EIP-712 domain and to its contracts, each read on chain, so a look-alike token gets none of its words. The wallet's lists are the person's own: an app or a token is named from them, never guessed.
The request the agent is handed#
// x402's EIP-3009 payment: the API's 402 answer names the payee and the amount, and the agent asks the key to sign.
/** @param {string} value */
const payment = (value) => ({
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: "0x857b06519E91e3A54538791bDbb0E22373e36b66",
to: "0x209693Bc6afc0C5328bA36FaF03C514EF312287C",
value,
validAfter: "1740672089",
validBefore: "1740672154",
nonce: "0xf3746613c2d920b5fdabc0856f2aeb2d4f88ee6037b8cc5d04a71a4462f13480",
},
});Confirm the terms, then check the request#
/** One task: the person confirms its terms, then the wallet checks the one request the agent hands it. */
/** @param {ReturnType<typeof payment>} typedData */
function task(typedData) {
const gate = termsGate();
const terms = readTerms({ token: "USDC", to: "Weather API", max_amount: "0.05", expires_by: "1 day" }, wallet);
const shown = gate.propose(terms);
gate.confirm(shown); // only after the person confirmed this text on the wallet's own screen
gate.read(); // from here the agent may read the request
const consent = eip712Consent({ resolved, typedData, chainId: 84532 });
return { shown, message: consent.message, verdict: gate.check(consent.grant, wallet, consent.digest) };
}
const real = task(payment("10000")); // 0.01 USDC, what the API costs
console.log(real.shown);
console.log(real.message);
console.log(real.verdict);
console.log(task(payment("25000000")).verdict); // the API asks for 25 USDC insteadnode quickstart.js prints the terms the wallet shows, the consent text of the real request, and two verdicts:
Weather API (0x209693Bc6afc0C5328bA36FaF03C514EF312287C) may be sent at most 0.05 USDC, until the end of 28 February 2025 (UTC).
# Pay USDC by signature
Send `0.01 USDC` from `0x857b06519E91e3A54538791bDbb0E22373e36b66` to `0x209693Bc6afc0C5328bA36FaF03C514EF312287C`, once. Valid after `2025-02-27 16:01:29 UTC`. Expires: `2025-02-27 16:02:34 UTC`.
- **Amount:** `0.01 USDC`
- **From:** `0x857b06519E91e3A54538791bDbb0E22373e36b66`
- **To:** `0x209693Bc6afc0C5328bA36FaF03C514EF312287C`
- **Valid after:** `2025-02-27 16:01:29 UTC`
- **Expires:** `2025-02-27 16:02:34 UTC`
**Contract:** `0x036CbD53842c5426634e7929541eC2318f3dCF7e` on chain 84532
**EIP-712 digest:** `0xf256992871671abcb27ff92885a7afa46218724e5fc0bac35d050115aa1d22e6`
This is a signature, not a transaction: whoever holds it can submit it.
{ fits: true, reasons: [] }
{
fits: false,
reasons: [ 'the request allows 25 USDC, the terms say at most 0.05 USDC' ]
}
fact Observed with @meantjs/profile and @meantjs/consent 0.9.0 from npm on
Node 22.23.5, on 2026-11-29 (0.8.0 printed the same on 2026-11-27). The real request fits, so it needs no second yes. The one that asks for 25 USDC does
not, and the reason says why in words the agent can pass on; the agent then asks the person for new terms. The same
request in the fields form, as a wallet would show it:
Pay USDC by signature
Send 0.01 USDC from 0x857b…6b66 to 0x2096…287C, once. Valid after 2025-02-27T16:01:29Z. Expires: 2025-02-27T16:02:34Z.
- Amount
- 0.01USDC
- From
- 0x857b…6b66
- To
- 0x2096…287C
- Valid after
- 2025-02-27T16:01:29Z
- Expires
- 2025-02-27T16:02:34Z
This is a signature, not a transaction: whoever holds it can submit it.
usdc-domain-usdcThird-party profile
A profile this wallet chose to trust.
Put the guard in front of the key#
A wallet does not have to call the check itself. guardSigner wraps a viem account, or x402's client
signer, which has the same shape, so that its signTypedData signs only a request a profile in
forms reads and whose grant fits the gate's confirmed terms, and nothing else: the guarded signer has
only address and signTypedData (and readContract when the wrapped signer has
one), so neither the agent nor x402's client can reach the key's signTransaction or
signMessage. With viem 2.57.4 and a local test key:
import { guardSigner } from "@meantjs/consent/guard";
import { privateKeyToAccount } from "viem/accounts";
const gate = termsGate();
gate.confirm(gate.propose(readTerms({ token: "USDC", to: "Weather API", max_amount: "0.05", expires_by: "1 day" }, wallet)));
// Anvil's first test account: a well-known key that must never hold funds.
const key = privateKeyToAccount("0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80");
const signer = guardSigner(key, { gate, wallet, chainId: 84532, forms: [resolved], now: () => wallet.now });
try {
await signer.signTypedData(payment("25000000"));
} catch (error) {
console.log(error.code, error.message); // nothing is signed
}E_GUARD_REFUSED the request does not fit the confirmed terms: the request allows 25 USDC, the terms say at most 0.05 USDC
fact Observed with the same packages and viem 2.57.4. Confirmed terms cover one request: once the gate
has checked one, signed or refused, the next is refused with EE_TERMS_ORDER ("another request is a new
task, with new terms"), so a guard over payment("10000") needs a gate of its own, and then signs it.
Give signer to x402's client (new ExactEvmScheme(signer)) or to a viem wallet client in
place of the key. examples/evm-signing-check
is a copyable version of this check: it replays 16 x402 and Permit2 requests on a local EVM that runs Base Sepolia's
USDC, Permit2 and x402 code, and fact the bare key signs all 11 bad ones while the check signs none of
them and all 4 real ones (its run).
What this does not cover yet#
- Transactions: the guard reads EIP-712 signing requests, not an
approveor a router call sent as a transaction. Consent text for calldata exists, and is experimental (Consent text for a call). - Agent tools, outcome classes over reverts and reconcile from receipts are Internet Computer only today (open question OQ-18).
- A request that no profile reads is refused (EE_GUARD_UNKNOWN), never guessed: a new contract needs its own profile first (Write a profile).