.x3 Developer Academy

Bootcamp

Learn the language. Understand the rules. Build something you can prove.

24 lessons · language and integration

NEAR intents & mandates + Rust compiler & local VM.

0 / 24 lessons marked complete

Saved on this browser. Self-assessed, not certification.

Source-backed reference

Curriculum: 3b6c730
Browser lab: 470d61a. Versions are intentionally explicit.

Intents integration

Execution and evidence

An intent is a desired outcome; a mandate is the owner’s authority. The compiler, Guard, provider infrastructure and chain verification have different jobs.

Implementation boundary

Read-only Explorer history is provider-reported, even when status says SUCCESS. A signed quote proves terms, not settlement. Guard acceptance is not funding. Keep Tidepool testnet evidence separate from official 1Click.

Checkpoint

Identify which assertions are local checks, provider reports, and independently verified chain evidence before enabling this feature.

Intents integration

Four swap types

EXACT_INPUT fixes origin units. EXACT_OUTPUT fixes destination units and applies slippage to the required input. FLEX_INPUT accepts variable deposits; the quote is not a spending cap.

Implementation boundary

ANY_INPUT is an ongoing collector: the supplied documentation specifies a $1,000 sweep threshold, no refunds, and partner authorization. This is not a universal minimum for ordinary swaps. Its creation deadline does not expire the collector. Do not enable ongoing collection under a one-payment mandate.

Checkpoint

Identify which assertions are local checks, provider reports, and independently verified chain evidence before enabling this feature.

Intents integration

Costs and application fees

Basis points: 100 = 1%. The requested app fee may differ from the amount charged after provider minimums. The generic public policy is only an illustration; actual partner configuration and quote terms govern.

Implementation boundary

Distinguish protocol, provider, application, network and withdrawal costs. Do not automatically add another website’s distribution fee. Price improvements may be shared; failed swaps can still incur costs. Confidential swaps have a separate fee arrangement. No application fee is activated here.

Checkpoint

Identify which assertions are local checks, provider reports, and independently verified chain evidence before enabling this feature.

Intents integration

Deadlines and signed terms

For local planning, dry quotes use the maximum window. Executable proposals use min(maximum, max(default, estimate)), bounded again by owner expiry. An estimate beyond the remaining window refuses execution.

Implementation boundary

The supplied narrative contradicted its 75-minute example. This lab explicitly adopts the capped example, not an asserted provider rule. Invalid estimates fail closed. Never mutate a signed quote: request a fresh quote, verify its signature, and rerun policy checks.

Checkpoint

Identify which assertions are local checks, provider reports, and independently verified chain evidence before enabling this feature.

Intents integration

Bridges and refund paths

Omni, POA and HOT are distinct routing infrastructures with different trust assumptions. Bridge choice and supported assets must come from current route metadata. Treasury, refill and change addresses are reference labels, never substitute deposit destinations.

Implementation boundary

The BTC connector refund flow is specific to a deposit that never finalized. It requires a request, timelock, execution and MPC signing. Check actual state and current required storage deposit; never automate refunds from this lesson. BTC/ZEC withdrawals may use single-use inputs, so treasury-sender matching alone is insufficient.

Checkpoint

Identify which assertions are local checks, provider reports, and independently verified chain evidence before enabling this feature.

Intents integration

Hyperliquid transfer boundaries

The supplied guide describes USDC credited to a perps balance, not spot or HyperEVM. That transfer does not itself place a derivative trade. Hyperliquid USDC uses 8 decimals; use integer quantities.

Implementation boundary

For deposits from Hyperliquid, the guide specifies 0.5 USDC minimum and 0.2 USDC fee. sendAsset/spotSend use quoted amountIn; usdSend additionally needs 1 USDC. Verify current quotes and supported methods. Direct bridge transfers to a quote address are not guaranteed. Derivatives access is not enabled here.

Checkpoint

Identify which assertions are local checks, provider reports, and independently verified chain evidence before enabling this feature.

Intents integration

Earn and receipt tokens

Earn routes payment assets into third-party receipt tokens using the quote/deposit/status flow. A receipt represents a position, not a guarantee of redemption, principal or yield.

Implementation boundary

Display the actual provider, receipt asset, withdrawal conditions, lockups and costs before owner approval. Availability through the API is not an audit or endorsement. This site has no enabled Earn execution path.

Checkpoint

Identify which assertions are local checks, provider reports, and independently verified chain evidence before enabling this feature.

Intents integration

Official SHIELD and X3 Shield

Official SHIELD communicates provider incidents; X3 Shield enforces owner policy. They are separate systems. Read incidents with a separate SHIELD credential. Incident submission needs additional provider permissions.

Implementation boundary

The incident API does not expose every surface security mode. Do not translate operational into Usual, or an incident into Under attack. Stale, malformed or unavailable data is unknown. Public views exclude internal descriptions, metadata and actor details. No incident submission is implemented.

Checkpoint

Identify which assertions are local checks, provider reports, and independently verified chain evidence before enabling this feature.

Intents integration

Solver lifecycle and NO_LIQUIDITY

Solver activity is separate from ordinary 1Click integration. It requires onboarding, KYC/KYB, controlled liquidity, signing infrastructure and operational controls. NO_LIQUIDITY does not provide financing.

Implementation boundary

Use swap_hash for deduplication after selection; update delivery estimates until liquidity is delivered. Confirm deadline units and how the escrow flow interacts with firm-quote obligations before live work. Do not fill coordinated self-originated hackathon intents. No solver bus connection or signing is enabled.

Checkpoint

Identify which assertions are local checks, provider reports, and independently verified chain evidence before enabling this feature.

Intents integration

Credentials and SDKs

Explorer, Swap and SHIELD access are separate capabilities. Keep credentials server-side. Use the official TypeScript, Go or Rust SDK matching the task; token metadata is available without authentication.

Implementation boundary

Preserve depositAddress and depositMemo together, use fresh deadlines, and distinguish dry quote simulation from mainnet execution. FAILED does not establish REFUNDED. Never paste credentials into lessons or commit them.

Checkpoint

Identify which assertions are local checks, provider reports, and independently verified chain evidence before enabling this feature.

Intents integration

Security and source references

Use published audit reports and the provider bounty program for their stated scopes. They do not prove that X3Lang or dotx3 has been audited. Provider screening coverage varies by flow.

Implementation boundary

Treasury references identify entities and address roles, not approved recipients or a proof of swap causality. Follow current official documentation and review source dates.

Checkpoint

Identify which assertions are local checks, provider reports, and independently verified chain evidence before enabling this feature.

01 / Foundations

Choose the right .x3 surface

What the language is, who enforces it, and where code runs.

The owner writes authority; the agent proposes actions

An intent describes a requested outcome: the input asset and amount, recipient, route, constraints, deadline and failure behavior. A mandate separately states what an agent is allowed to request. Model output is input to the checker, never an authorization by itself.

X3 Shield combines policy compilation, quote checks and a NEAR Guard contract. These are distinct stages. Passing a browser check proves a local calculation over supplied data. It does not prove live mandate state, a wallet signature, a transfer or finalized delivery.

X3 Shield and official NEAR SHIELD

X3 Shield is this project’s .x3 compiler, owner-mandate checks and NEAR Guard workflow. Official NEAR Intents SHIELD is a separate incident and security-policy service used by integrated NEAR Intents surfaces. A shared name does not establish integration, endorsement or equivalent enforcement.

Two toolchains, two contracts with the developer

The Python intent/mandate tools are the shipping NEAR adapter surface. near_intents.py prepares and checks requests; near_mandate.py compiles owner policies. The Rust x3c compiler has a broader language surface, produces X3BC and runs with a local VM and capability host. The documented Rust instruction set is not loaded by a chain pallet.

Choose your target before copying syntax. A clause accepted by a parser is not necessarily lowered or enforced by a particular backend. In particular, the generic Rust VM has no mandate store: under mandate does not create wallet enforcement.

Checkpoint

Explain the difference between a locally valid policy, on-chain authorization and a finalized transfer before continuing.

02 / Tooling

Install, pin and call the tools

Source installation and reproducible command-line entry points.

Start from a known revision

Use Python 3.11+, Rust 1.90+ with Cargo, and Node.js 22+ for browser tests. Installation downloads dependencies; the subsequent fixture-based lessons need no wallet or signing key. The browser lab below uses an independently pinned, older checker; its revision is displayed rather than silently equated with current master.

Commands / example

git clone https://github.com/Cyptopimpinainteazy/x3lang.git
cd x3lang
git checkout 3b6c73037a1cb158f79c5f76d3ee202c4376f8d4
python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install -r x3-lang/requirements.txt pytest
git rev-parse HEAD

Select the entry point

cli.py is a parser boundary that emits a JSON AST for one intent. It intentionally skips other top-level declarations; using it alone cannot validate a whole Rust program or certify its policy enforcement. Use the adapter for NEAR lowering and x3c for the Rust surface. Ask each CLI for its supported arguments at your pinned revision.

Commands / example

python3 x3-lang/cli.py x3-lang/examples/near_intents_agent_payment.x3
python3 x3-lang/near_intents.py --help
cargo run --manifest-path x3-lang/Cargo.toml --locked -p x3-tools --bin x3c -- --help

Checkpoint

Record the commit and tool versions alongside the first command output. Do not copy another revision’s pass counts.

03 / Language

Read an intent line by line

Endpoints, route, requirements, deadlines and failure behavior.

The program envelope

intent NAME { ... } declares the payment program. from names chain.asset, an integer amount and the source receiver. to names the destination asset and its receiver. route encloses operations, with semicolons on the route steps in the examples. Use the complete checked-in example below as your starting point.

In the Python surface, blank lines and full-line // or # comments are ignored; trailing comments are supported by its line cleaner. That does not make the syntax rules of every other frontend identical. Keep examples formatted like their target’s checked-in files.

Constraints are obligations

require slippage <= 0.5% sets an upper bound; require fees <= 100 bps sets a fee ceiling. require nonce unused NAME names a one-use identifier. under mandate OWNER associates the intent with an owner’s policy; it is not a declaration of that policy.

timeout 10m refund Solana.USDC specifies a refund path at the deadline. On the NEAR adapter, on_fail rollback is translated into refund semantics; it is not an instantaneous cross-chain reversal. An unsupported halt or quarantine promise is refused. The generic Rust path has its own policy checks.

Checkpoint

Locate who receives a successful payment and who receives a refund. They are separate terms.

04 / Types

Amounts, assets, addresses and time

Avoid the mistakes that turn a correct-looking program into a bad payment.

Base units are integers

Amounts are integer base units, not display decimals. For a token with six decimals, 25 units is 25000000. Check token metadata rather than guessing decimals from a symbol. The mandate amount must fit u128; per_payment must be positive and cannot exceed per_24h.

One basis point is 0.01%; 50 bps is 0.5%. The Rust guide documents bare 50 and 0.5% as equivalent slippage bounds, and 100 bps or 100bps for fee ceilings. Use the demonstrated percent/bps spellings in the NEAR track. A cap is not a promise that a quote will meet it.

Symbols are not token identities

Chain aliases and symbols are resolved through registries and token records. A registry entry is not evidence of a deployed integration. Resolve a concrete originAsset/destinationAsset from the token catalog and bind the correct network. Do not substitute similarly named tokens or compare Solana addresses case-insensitively.

The parser accepts some short EVM placeholders for source compatibility. Passing its address-shape check does not prove a real address, ownership, network or recipient intent. Example accounts are teaching fixtures, not deposit instructions.

Relative time needs a clock

A mandate expires duration is compiled relative to compilation time. The checker requires now to be strictly before expiry and the payment deadline to be no later than mandate expiry. Recompiling later changes the computed expiry even when the source is unchanged. Record both source hash and evaluation time.

The local lab deliberately freezes the clock to the scenario fixture timestamp. Its old-looking expiry is not a statement about a currently active on-chain mandate.

Checkpoint

Convert 30 USDC at six decimals to base units, and explain why changing the token requires checking its decimals again.

05 / Authority

Write every mandate term

The owner policy, explained field by field.

Identity and spend scope

owner identifies the NEAR owner; agent identifies the account acting under the mandate. spend fixes the origin asset. per_payment bounds one payment, while per_24h bounds a rolling 24-hour window. These are not interchangeable: a small payment can still exhaust a rolling allowance.

allow recipients is a list of permitted destination accounts; allow assets is a list of permitted destination assets. Lists must be nonempty, distinct and within the implementation’s length limits. refund_to pins an explicit source-chain account, not the symbolic sender.

Price bounds and approvals

Both require slippage and require fees must be bounded. If multiple bounds are present, lowering uses the tightest. Compiled ceilings cannot exceed 10000 bps. The payment’s declared caps must not loosen the owner’s caps.

approve above AMOUNT by N of ACCOUNTS makes payments strictly above AMOUNT require approvals. Equality is not above. The approval amount must be below per_payment, approvers must be distinct and valid, N must be between one and the number of approvers, and the agent cannot approve its own payments.

Expiry, history and revocation

expires ends the authority at a computed time. The rolling check sums payments strictly inside its 24-hour window and also caps payment count. The checked-in example describes a maximum of 64 payments per window. A locally compiled mandate has no real spend history or revocation state unless you supply state.

A deployed Guard maintains state and must recheck authority when accepting the request. Revocation and replay are stateful contract concerns. Never turn an old local pass into a current authorization. The source hash records identity; each execution path must actually enforce the binding to make it meaningful.

Checkpoint

Change the recipient in the lab while keeping the mandate unchanged. The payment must be refused.

06 / Adapter rules

The NEAR path is deliberately narrow

Which programs lower to 1Click, and which must be refused.

One leg with matching endpoints

The adapter accepts one NearIntents bridge leg and no fallback route. Its origin and destination assets must match the intent endpoints. A second swap or a fallback is not silently treated as part of an atomic transaction.

An explicit slippage bound and timeout are required. A mandate payment requires exactly one replay-protection nonce. Refunds must use the deposited asset on the origin chain, and timeout/on_fail refund destinations must agree.

No unenforceable promises

Only guards supported by this adapter may pass lowering. A broader compiler vocabulary is not a license to attach unsupported guards to a NEAR request. X3_NEAR_GUARD_UNENFORCEABLE means the selected backend cannot keep the promise.

The searchable refusal index below is extracted from the pinned Python parser, adapter and mandate compiler. It includes exact source locations. It is a diagnostic index for those files, not a claim that it exhausts the Rust verifier, VM traps or deployed contract errors.

Checkpoint

Remove the slippage requirement, then add a second route leg. Learn the different compiler refusals instead of deleting safeguards until the program passes.

07 / Integration

Call .x3 from a terminal or application

Plan, policy-check and integrate structured output safely.

Choose the integration level

1Click is the higher-level cross-chain swap workflow: request a quote, fund the reviewed deposit, then track the result. The Intents SDK exposes lower-level intent execution and withdrawal operations. It is a separate integration surface, not another name for the .x3 compiler or the 1Click SDK libraries.

Official NEAR Intents has no testnet version according to its quickstart. The historical Base Sepolia to NEAR testnet Tidepool route is a separate trusted-relay experiment; it is not official 1Click testnet settlement. An explorer or distribution-channel API key provides access, not a funded-swap receipt or proof of destination settlement.

Plan without requesting a quote

plan compiles an intent into a quote request. It does not ask for a quote. Supplying --tokens uses a saved token catalog; omitting it fetches the live catalog. tokens.json below is a catalog you obtain and review, not a file that this page installs.

Commands / example

python3 x3-lang/near_intents.py plan \
  x3-lang/examples/near_intents_agent_payment.x3 --tokens tokens.json
python3 x3-lang/near_intents.py mandate check \
  x3-lang/examples/near_mandate_agent.x3 \
  x3-lang/examples/near_intents_agent_payment.x3 --tokens tokens.json

Call the CLI with an argument array

For a server integration, run the pinned tool in a constrained process, pass paths as arguments, and parse its JSON output. Never concatenate untrusted .x3 source into a shell command. Nonzero exit is a refusal or failure to handle, not permission to fall back to an unchecked request.

Use an allowlisted working directory, cap input/output size and runtime, and keep source separate from credentials. This example only runs the offline plan with a supplied catalog.

Commands / example

import json, subprocess
result = subprocess.run(
    ["python3", "x3-lang/near_intents.py", "plan",
     "payment.x3", "--tokens", "tokens.json"],
    capture_output=True, text=True, timeout=30, check=False,
)
if result.returncode != 0:
    raise RuntimeError(result.stderr or "X3 plan refused")
plan = json.loads(result.stdout)

Browser integration

This site vendors the browser checker with hashes and a provenance record. Its judge.evaluate function accepts the scenario dataset and an intent/state scenario, then returns a decision, checks and denied_guards. The lab uses that code directly. It performs no remote quote request or transaction.

The browser port is not a complete Rust compiler SDK. To add a new language feature, change the authoritative implementation and parity tests first, then refresh the vendored files and hashes.

Checkpoint

Handle both a zero-exit plan and a nonzero refusal in your application without invoking a signer in either case.

08 / Quotes

From a request to checked quote terms

Dry mode, signatures, freshness and owner review.

Dry quote is a network operation

quote defaults to dry mode and calls the quote service. It checks the response against the program and can write structured evidence with --out. A dry quote is not a settlement or proof that a deposit exists. Token availability and service responses can change.

Commands / example

python3 x3-lang/near_intents.py quote \
  x3-lang/examples/near_intents_agent_payment.x3 \
  --mandate x3-lang/examples/near_mandate_agent.x3 \
  --tokens tokens.json --out dry-quote.json

Bind the response before using it

Validate the configured manager signature, exact signed payload and quote hash, then check freshness, amount, assets, recipient, deadline, refund and price bounds. A valid signature does not itself mean the quote meets the owner’s policy. A provider status string does not prove chain finality.

--live is a separate operational step: it requests a real deposit address, consumes local nonce state and writes a receipt. It does not sign the deposit. This course does not run it. Review the exact network, accounts, amounts and receipt before any separate wallet authorization.

Checkpoint

Explain why “signed”, “within policy”, “authorized” and “settled” are four different claims.

09 / Contract boundary

Prepare Guard calls and verify execution

How arguments become transactions—and why the distinction matters.

Generate arguments, do not assume they were sent

mandate args produces create_mandate arguments. mandate revoke produces revoke_mandate arguments. These commands print data or a command; generating revocation arguments does not revoke anything on-chain. Guard calls need the correct signer, network, contract, gas and attached deposit.

Commands / example

python3 x3-lang/near_intents.py mandate args \
  x3-lang/examples/near_mandate_agent.x3 --tokens tokens.json
python3 x3-lang/near_intents.py prepare \
  --receipt reviewed.near-receipt.json --program payment.x3

Authorization is separate from custody

Agent methods register and accept a request under the mandate, and listed approvers use the contract’s approval path where required. Read the contract method definitions and generated arguments at your revision rather than inventing JSON fields or using an old contract ABI.

The Guard described in this track holds no funds. A keyholder can bypass it by directly using the origin wallet. A scoped vault can change that architecture only after its code, authority boundaries and deployed instance have been independently verified.

Observe and verify the result

status reports an observed outcome. verify-deposit and verify-settlement perform their respective evidence checks and update a receipt. submit-deposit notifies 1Click of a transaction hash only after the implemented checks; it is an external side effect, not a read-only query.

Record the exact source hash, quote binding, authorization transaction, origin transfer and destination evidence. A local receipt or two unrelated transaction hashes cannot establish cross-chain causality by themselves.

Checkpoint

Draw your integration’s boundary between preparing arguments and a human-approved signer. No model-generated command may cross it automatically.

10 / Compiler & VM

Build and inspect X3BC

The Rust language track, capability hosts and local execution.

Compilation stages

The documented pipeline is source → lexer/parser → typed AST → semantic checks → X3IR → X3BC emitter → bytecode verifier → VM. Each stage answers a different question. Parsing recognizes syntax; semantics reject unsupported claims; verification checks the instruction stream; execution needs an actual host.

Determinism means the same source, compiler revision and options produce the same result. Pin all three. A bytecode file is not a signed transaction. Local VM gas is not a host chain’s fee quote.

Commands / example

cargo run --manifest-path x3-lang/Cargo.toml --locked -p x3-tools --bin x3c -- check x3-lang/examples/simple_swap.x3
cargo run --manifest-path x3-lang/Cargo.toml --locked -p x3-tools --bin x3c -- build x3-lang/examples/simple_swap.x3 -o /tmp/simple_swap.x3b
cargo run --manifest-path x3-lang/Cargo.toml --locked -p x3-tools --bin x3c -- explain /tmp/simple_swap.x3b

General programs and host effects

The Rust compiler accepts functions, bindings, mutation, branches, loops, returns, function types, tuples and arrays. The checked-in events_and_host_calls example below demonstrates fn main, emit, subscription, @subscribe and @sponsor without inventing an SDK.

A capability call names an external effect; a matching capability host must implement it. A compiled subscription is not evidence that a keeper is running. Inspect the parser and tests for precise grammar and type combinations; do not assume every Rust-looking construct is part of .x3.

Checkpoint

Build the events example and inspect its decoded instructions. Identify which operations require a host.

11 / Enforcement

Guards, policies, proofs and failure

How to reason about a promise the backend must actually enforce.

The guard vocabulary

The Python registry includes finality, slippage, fees, profit, invariant, risk, nonce, audit_gate, bridge_liquidity, canonical_supply, relayer_quorum, route_score, solver_bond, proof_complete, refund_path, refund_to, finality_explicit, vm_supported and mainnet_safe. It also accepts the legacy spelling proof. The parser’s vocabulary does not assert that every backend enforces all of them.

The Rust guide identifies X3E4027 for a fee ceiling without backing policy. GuardClaimUnbacked means no pass can substantiate a claim. Do not remove a safety condition merely to get a green compiler result; select a supported target or implement the missing checker and adversarial tests.

Evidence must come from somewhere

proofs required records obligations such as source_lock_proof and destination_fill_proof. It does not manufacture evidence. Verification against a supplied root is not the same as authenticating the root against an independent trust anchor.

The documented NEAR light-client boundary does not establish an independently authenticated production checkpoint, deployed escrow code hash or terminal escrow storage state. Treat RPC agreement, verified=true fields and trusted flags as data to evaluate, never consensus proof.

Rollback scope is target-specific. A local transaction journal cannot undo an already-finalized external chain action. For the NEAR quote path, refunds follow the adapter/service semantics; do not describe a multichain route as atomic merely because the source says rollback.

Checkpoint

For every require in your program, name the component that checks it and the evidence that component consumes.

12 / Graduation

Test hostile inputs and ship evidence

A developer’s completion criteria, not a marketing checklist.

Make refusal a tested behavior

Start with a valid fixture. Change one property at a time: recipient, origin or destination asset, amount, fee cap, slippage cap, refund address, nonce or deadline. Assert the specific failed guard or compiler code. Then test boundary equality, expiry, revocation, rolling spend and duplicate submissions at the layer that owns that state.

Keep browser/Python parity tests and contract tests distinct. A replay contract test is not a browser replay defense. Never repair a failed test by fabricating chain state or replacing a verifier with a success flag.

Commands / example

PYTHONPATH=x3-lang python3 -m pytest x3-lang/tests -q
node --test x3-lang/near/demo/test/*.test.mjs
cargo test --manifest-path x3-lang/Cargo.toml --locked -p x3-lang-vm --quiet
cargo test --manifest-path x3-lang/near/x3-guard/Cargo.toml --locked --quiet

A reproducible handoff

Include source revision and hash, compiler/tool versions, token catalog identity, evaluation time, generated terms, exact test commands and results. Label local, fixture, dry-network, testnet and independently verified settlement evidence separately.

Keep private keys, seed phrases and API credentials out of source, screenshots and receipts. Review generated files before publication. Require independent review before enabling a signer or payout. Graduation here is local learning progress, not a certification of deployment safety.

Checkpoint

Demonstrate one local pass, one policy refusal and one compile refusal, then explain what none of those results prove about settlement.

Quote planning lab

Local illustration, not a live quote. Standard window: 30 minutes; maximum and owner window: 60 minutes. Requote and verify signatures before any execution. Generic fee policy may differ from your agreement.

No calculation yet. This lab never sends funds.

Download the Intents field manual

Complete source examples

Unmodified files from the curriculum revision. Accounts are examples, not destinations to fund. Select the matching toolchain before running.

near_mandate_agent.x3

NEAR adapter track

// near_mandate_agent.x3 — what an owner lets an AI agent spend, enforced on NEAR by x3-guard.
//
// The owner sends this once (`near_intents.py mandate args`). From then on the agent account
// can register swaps in the owner's name, and x3-guard refuses any that break a term:
//
// - `spend` and `per_payment`: Solana USDC only, at most 50 USDC a payment.
// - `per_24h`: at most 200 USDC in any rolling 24 hours (and at most 64 payments).
// - `allow recipients` / `allow assets`: where the money may go, and as what.
// - `refund_to`: a failed swap refunds here. The agent cannot point refunds at itself.
// - `require slippage` / `require fees`: the loosest bounds an agent's intent may declare.
// - `approve above`: a payment over 30 USDC waits for one of the listed approvers.
// - `expires`: the mandate ends 30 days after it is compiled. The owner can revoke it at
//   any time (`near_intents.py mandate revoke`), and every unaccepted intent stops at once.
//
// Amounts are base units: 50 USDC at six decimals is 50_000_000.
//
// The accounts are placeholders. Replace them with accounts you control.
mandate x3_shopping_agent {
    owner x3-owner.near
    agent x3-agent.near
    spend Solana.USDC
    per_payment 50000000
    per_24h 200000000
    allow recipients x3-demo.near
    allow assets Near.USDC
    refund_to 4Nd1mzi8Y1QYxJt9wZWBYZpG7S4pYkZs6YzD3Vt9aBcD
    require slippage <= 1%
    require fees <= 100 bps
    approve above 30000000 by 1 of x3-owner.near
    expires 30d
}
Source
near_intents_agent_payment.x3

NEAR adapter track

// near_intents_agent_payment.x3 — an AI agent's payment, under its owner's mandate.
//
// The same NEAR Intents swap as `near_intents_sol_to_near.x3`, with one more clause:
// `under mandate x3-owner.near`. The agent account registers and accepts it through
// x3-guard's agent methods, which check `near_mandate_agent.x3`'s terms on chain first:
//
//   near_intents.py mandate check near_mandate_agent.x3 near_intents_agent_payment.x3
//   near_intents.py quote near_intents_agent_payment.x3 --live --mandate near_mandate_agent.x3 \
//       --guard-contract <x3-guard account>
//
// 25 USDC is under the mandate's 30 USDC approval threshold, so no approval is needed.
intent near_intents_agent_payment {
    from Solana.USDC amount 25000000 receiver 4Nd1mzi8Y1QYxJt9wZWBYZpG7S4pYkZs6YzD3Vt9aBcD
    to Near.USDC receiver x3-demo.near
    route {
        bridge NearIntents Solana.USDC -> Near.USDC min_receive 24800000;
    }
    under mandate x3-owner.near
    require slippage <= 0.5%
    require fees <= 100 bps
    require nonce unused agent_payment_001
    timeout 10m refund Solana.USDC
    on_fail rollback
}
Source
simple_swap.x3

Rust compiler track

finality_policy strict {
    chain arbitrum
    requirement finalized
    blocks 32
}

finality_policy strict {
    chain solana
    requirement finalized
    blocks 32
}

risk_policy {
    min_route_score 90
}

intent simple_swap {
    from arbitrum.USDC amount 500
    to solana.SOL receiver wallet

    route {
        bridge X3 arbitrum.USDC -> solana.SOL receiver wallet
    }

    require nonce unused simple_swap_001
    require finality.arbitrum >= 32
    require finality.solana >= 32
    require slippage <= 50
    require route_score >= 90

    timeout 180s refund arbitrum.USDC to sender
    on_fail rollback
}

// The bridge above cannot be claimed on the far side without evidence that the
// source chain locked the funds and that the destination chain filled them.
// Those are this program's proof obligations, so it declares them rather than
// leaving the verifier to warn about each one.
proofs required {
    source_lock_proof
    destination_fill_proof
}
Source
events_and_host_calls.x3

Rust compiler track

// `emit` and a host call — the two instructions whose payload the compiler wrote by hand.
//
// Both go to the host (`emit` to the EVM backend, a call to the SVM backend), and both used to
// build an artifact the verifier refused with `X3_VERIFY_FAILED: InvalidOperand`: the emitter
// formatted the payload itself as `"{name}:{args:?}"` while the shared decoder had no arm for
// `EMIT` (`0x60`) or `CALL_HOST` (`0x61`), and the string it wrote carried the compiler's own Rust
// `Debug` output. They are records now, and this is the smallest program that exercises them:
//
//     x3c build examples/events_and_host_calls.x3 -o /tmp/events.x3b
//     x3c explain /tmp/events.x3b      # the event and the calls, as records
//     x3c run /tmp/events.x3b          # executes every instruction

// A subscription item states its rate and charges through the host by name.
subscription keeper: 100, 30 {
    emit Charged(100);
}

// `@subscribe` and `@sponsor` are host calls too: neither is a statement the VM can execute on
// its own, so each asks the host for one by name.
@subscribe(TransferDone)
@sponsor
fn main() {
    emit TransferDone(1);
}
Source

Practice lab

LOCAL POLICY ONLY · NO WALLET

Edit the owner mandate and payment, then run the real vendored checker. Uses captured token metadata, a fixed clock (2026-11-03T03:00:00Z), no previous spends and no revocation. It does not query live Guard state, request quotes, detect on-chain replay, or send funds. Examples here come from browser revision 470d61a.

Ready to check

No result yet. Editing clears the previous result.

Refusal reference

71 code/source entries extracted from the pinned Python parser, NEAR adapter and mandate compiler. Search at the top of the page. Dynamic messages are explained at the linked source line. For the complete Rust grammar and verifier rules, use the source references in lessons 10–11.

X3_EVIDENCE_BASELINE

the receipt has no starting balance, so a delivery cannot be measured

near_intents.py:1797

X3_EVIDENCE_BINDING

the receipt's program SHA-256 does not match the supplied X3 program

near_intents.py:1464

X3_EVIDENCE_TX

no deposit transaction: pass --tx, or record it with submit-deposit --receipt

near_intents.py:1655

X3_EVIDENCE_UNSUPPORTED

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:1141

X3_EVIDENCE_UNVERIFIED

a finalized, correct Solana transfer must be proven before notifying 1Click

near_intents.py:2065

X3_MANDATE_ACCOUNT

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_mandate.py:182

X3_MANDATE_APPROVAL

`approve above` must be below per_payment, or no payment could need it

near_mandate.py:256

X3_MANDATE_ASSET

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_mandate.py:173

X3_MANDATE_BOUND

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_mandate.py:241

X3_MANDATE_CHAIN

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:1300

X3_MANDATE_DENIED

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:1316

X3_MANDATE_EXPIRES

expires must fit a UTC timestamp from 1970-01-01T00:00:00.000Z through 9999-12-31T23:59:59.999Z

near_mandate.py:149

X3_MANDATE_LIST

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_mandate.py:235

X3_MANDATE_OWNER

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:1290

X3_MANDATE_RECIPIENT

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_mandate.py:227

X3_MANDATE_REFUND_TO

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_mandate.py:231

X3_MANDATE_REQUIRED

a live quote for a mandate-controlled intent requires --guard-contract so revocation and rolling spend are read from chain state

near_intents.py:1161

X3_NEAR_ACCOUNT_UNKNOWN

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:1024

X3_NEAR_AMOUNT

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:292

X3_NEAR_ASSET_AMBIGUOUS

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:529

X3_NEAR_ASSET_UNSUPPORTED

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:523

X3_NEAR_BOUND_UNIT

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:321

X3_NEAR_CHAIN_UNSUPPORTED

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:356

X3_NEAR_ENDPOINT

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:353

X3_NEAR_GUARD_FAILED

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:866

X3_NEAR_GUARD_OPERATOR

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:329

X3_NEAR_GUARD_STEP

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:1388

X3_NEAR_GUARD_UNENFORCEABLE

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:412

X3_NEAR_HTTP

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:939

X3_NEAR_INVALID_SIGNATURE

Cryptographic quote verification failed; deposit prohibited

near_intents.py:771

X3_NEAR_NONCE_STORE

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:1040

X3_NEAR_NONCE_USED

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:1068

X3_NEAR_NOT_TERMINAL

the receipt records no terminal status yet; run `status --wait --receipt` first

near_intents.py:1410

X3_NEAR_NUMBER

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:284

X3_NEAR_ON_FAIL_UNSUPPORTED

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:455

X3_NEAR_PROVIDER_MINIMUM

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:932

X3_NEAR_RECEIPT

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:1384

X3_NEAR_REFUND_ASSET

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:471

X3_NEAR_REFUND_TO

the refund goes to `sender`, and `from` names no receiver to refund

near_intents.py:480

X3_NEAR_ROUTE_ENDPOINTS

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:384

X3_NEAR_ROUTE_SHAPE

a NEAR Intents program has exactly one route leg, `bridge NearIntents <from> -> <to>`: 1Click settles one swap, and composing it with other legs would allow partial execution with no rollback

near_intents.py:370

X3_NEAR_RPC

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:1011

X3_NEAR_SLIPPAGE_REQUIRED

a NEAR Intents swap needs `require slippage <= <bound>`; 1Click requires a tolerance and this adapter will not pick one for you

near_intents.py:421

X3_NEAR_STATUS_UNKNOWN

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:1846

X3_NEAR_TIMEOUT_REQUIRED

a NEAR Intents swap needs `timeout <duration> refund <from asset>`: the deadline is when 1Click starts refunding, and it is the program's to state

near_intents.py:444

X3_NEAR_TIMEOUT_UNIT

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:244

X3_NEAR_TIMESTAMP

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:267

X3_NEAR_TOKENS

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:1117

X3_NEAR_UNREACHABLE

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

near_intents.py:890

X3_PARSE_AMOUNT

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

cli.py:137

X3_PARSE_ASSET_REF

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

cli.py:106

X3_PARSE_BRIDGE

expected bridge <via> <from> -> <to>

cli.py:295

X3_PARSE_DECLARATION

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

cli.py:361

X3_PARSE_ENDPOINT

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

cli.py:132

X3_PARSE_FALLBACK

expected a fallback block

cli.py:230

X3_PARSE_MANDATE

expected `under mandate <owner account>`

cli.py:469

X3_PARSE_NO_INTENT

this file declares no `intent`: this surface reads one intent per file, and every top-level item here is a declaration it skips. A file whose subject is a bare `atomic_choice`, `strategy`, `objective` or `parallel` block is a program for the compiler, not an intent for this surface

cli.py:383

X3_PARSE_OPERATION

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

cli.py:323

X3_PARSE_RECEIVER

receiver requires an address

cli.py:114

X3_PARSE_REFUND

expected refund <chain.asset> [to <receiver>]

cli.py:153

X3_PARSE_REQUIRE

Context-dependent refusal. Inspect the exact condition and diagnostic in the pinned source.

cli.py:208

X3_PARSE_SWAP

expected swap <dex> <from> -> <to>

cli.py:283

X3_PARSE_TIMEOUT

timeout requires a duration

cli.py:458