Learn .x3

Write the rule. The agent does not get to waive it.

X3 is the owner's typed policy and the agent's payment program. A deterministic compiler and x3-guard on NEAR compare them. Model output never authorizes a deposit.

What is dotx3?

dotx3 is the public front door for the language, tools and evidence. A .x3 file is the program you write.

Owner mandate

Define the agent, spending asset, allowed recipients, payment and daily caps, approval threshold, refund address and expiry.

Payment intent

State what the agent wants to pay: source amount, destination asset and recipient, minimum output, mandate reference, nonce and deadline.

Check, then authorize

The frontend checks source. Guard checks signed quote terms on NEAR. A wallet funds separately, and settlement needs its own evidence.

Quickstart

Run these commands from a checkout of the X3Lang repository, not the dotx3 website. The local policy demo needs no wallet or API key and signs nothing. The bootcamp explains the language in depth.

Install

git clone https://github.com/Cyptopimpinainteazy/x3lang.git
cd x3lang
python3 -m venv .venv && . .venv/bin/activate
pip install -r x3-lang/requirements.txt pytest

Hash the trade program, then run the suite

sha256sum x3-lang/examples/base_sepolia_to_near_testnet_1usdc.x3
python3 x3-lang/cli.py x3-lang/examples/arb_solana_eth.x3
PYTHONPATH=x3-lang python3 -m pytest x3-lang/tests -q

Run the current tests and retain the commit hash with the result. Contract checks are separate: cd x3-lang/near/x3-guard && cargo test --locked. Historical test counts are not proof for your checkout.

Syntax

Owner mandate

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
}

Agent payment under the owner mandate

// 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
}

The program behind the testnet trade

intent x3_testnet_base_usdc_to_near {
    from BaseSepolia.USDC amount 1000000 receiver 0x5aF0c1BF95B3A158f6Fc48e3DED35903b2fa0721
    to Near.USDC receiver x3lang.testnet
    route {
        bridge NearIntents BaseSepolia.USDC -> Near.USDC min_receive 980000;
    }
    require slippage <= 1%
    require nonce unused x3_base_testnet_trade_001
    timeout 30m refund BaseSepolia.USDC to 0x5aF0c1BF95B3A158f6Fc48e3DED35903b2fa0721
    on_fail rollback
}

Mandate file · Trade file · All examples

Read the amounts and limits

Integer token units

For six-decimal USDC, 25000000 means 25 USDC. Confirm the token registry and decimals before adapting examples. 100 bps means 1%.

Explicit permission

The example caps each payment at 50 USDC and a rolling day at 200 USDC. Above 30 USDC, an owner approval is required. Approval does not waive a cap.

A bounded request

Use a fresh nonce for each payment. Keep the origin refund address, minimum receipt and timeout explicit. Unsupported NEAR route shapes fail compilation.

Compiler and execution

What compiles today

The Python frontend parses, type-checks, and checks mandates. Unsafe edits fail before a quote. Nine checked-in edits are refused at compile time, including a dropped nonce and a look-alike recipient.

What runs on NEAR

x3-guard stores the policy and rechecks quote terms. It holds no funds. Acceptance is not permission to send from an origin wallet.

What does not run on a block

The x3-lang intent VM executes in this workspace only. The README says it is not loaded by a pallet. Do not describe a local simulate as chain execution.

LimitThis installation guide uses source. Check the current release artifacts separately. Programming notes live in the repo under docs/x3-lang. Judge steps: docs/hackathon.