Skip to content

feat(engine): cross-chain stablecoin quotes through NEAR Intents, with 1Click's signature as proof (#273) - #278

Merged
Lexirieru merged 7 commits into
mainfrom
feat/engine-crosschain-quote
Nov 12, 2026
Merged

Lexirieru merged 7 commits into
mainfrom
feat/engine-crosschain-quote

Conversation

@Lexirieru

Copy link
Copy Markdown
Contributor

Engine part of #273. A Payments Mind can quote a USDC/USDT payment from NEAR to any chain NEAR Intents supports, and show that the numbers are NEAR Intents' own.

What

  • crosschain_quote (engine/src/crosschain.ts), in the payments skill. The Payments Mind template already carries that skill, so owners add nothing.
    • Calls 1Click POST /v0/quote with dry: true: no deposit address, no transaction, no API key (HACKATHON.md Q-006/Q-007).
    • Asset ids come from GET /v0/tokens; amounts are converted in BigInt; refundTo is the Mind's own wallet address. No approval, since nothing moves.
  • Proof. 1Click signs every quote. The result carries proof: { signedBy1Click, signature, quoteHash, publicKey }, checked with the official verifyQuoteSignature from @defuse-protocol/one-click-sdk-typescript 0.1.26, pinned.
    • A real quote verifies; the same quote with amountOut changed does not.
    • test/fixtures/oneclick-dry-quote.json is a real signed dry quote.
  • What the Mind says. It always states it is a preview and that nothing was sent: NEAR Intents is mainnet only and our wallets are testnet. Unasked, it says NEAR Intents signed the numbers and the signature checked out.
    • It never retypes the hash or signature. When it tried, it dropped characters (3 of 6 runs), so the exact values belong on an FE card.
  • Default NEAR RPC is now https://test.rpc.fastnear.com (listed at docs.near.org/api/rpc/providers). rpc.testnet.near.org answered "THIS ENDPOINT IS DEPRECATED! STOP USING IT NOW!" on and off today, which failed near_view_account and 11 tests in one full run.
    • @Lin1er: after the deploy the hosted engine uses it with no `engine.env` change, unless `NEAR_RPC_URL` is set there to the old endpoint.
  • No backend change. Docs: engine/CLAUDE.md, docs/api-contract.md, engine/.env.example.

Tests (local)

  • bun run typecheck: passes.
  • bun run test:unit: 178/178.
  • bun run test with the FastNear default: 317/318.
    • The one failure: in "agents inside a workflow never get approval tools" the model tried send_payment. Workflows don't have it, so it got ToolNotFoundError, with no card and nothing paid.
    • That test then passed 5/5 on this branch and 5/5 with main's playbook.
    • The run before the RPC change had 11 failures, all from the deprecated RPC. Each file passed when rerun on FastNear: near-tool 3/3, workflows 9/9, skills-wallet incl. lookalike 3/3, autopilot 7/7.
  • Live prompt test test/skills-crosschain.test.ts (14-skill Payments Mind, fake 1Click): 9/9 in 3 runs. It covers Base USDC (signed, so the reply must say signed), Solana USDT (unsigned, never called verified), and a NEAR payment still going to send_payment with its card.
  • Load: load/chat.js 2 VUs 20 s, 20/20 checks; load/workflow.js 20 s, 15462/15462 checks.
  • Chrome e2e, local stack, real 1Click, Payments Mind:
    • 10 USDC → Base: 9.99558 USDC, cost 0.00442, ~22 s.
    • 25 USDT → Solana: 24.984984 USDT, ~17 s.
    • A plain Indonesian request got the proof without being asked.

For @AncungAulia

  • Card (optional, makes the proof exact). On the tool.result of crosschain_quote, show from.amount from.token → to.amount to.token on to.chain, then cost, seconds, and "Preview only, nothing sent". Add a "Signed by NEAR Intents" line that opens proof.quoteHash, proof.publicKey and proof.signature, copied straight from the result. No pay button.
  • Words for runs/data/tools.ts: crosschain_quote: { doing: "Getting a cross-chain quote", done: "Got a cross-chain quote", orb: "searching", node: "Cross-chain quote" }.
  • Also in progress: View proof: open the TEE Explorer report already verified, no pasting #277. The "Paste the quote in TEE Explorer" link will open the report already verified: a backend route uploads the Intel quote to proof.t16z.com, and you get a URL to open.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e

Lexirieru and others added 7 commits November 12, 2026 21:09
…in payments (#273)

NEAR Intents has no testnet and HelloNear wallets are testnet, so this is a
preview only: 1Click POST /v0/quote with dry: true (no deposit address, no
transaction, no key). Asset ids from GET /v0/tokens, amounts in BigInt,
refundTo is the Mind's own wallet address.

Tests: test/crosschain.test.ts 5/5 (fake 1Click); one live dry quote by hand:
10 USDC on NEAR -> 9.99558 USDC on Base.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
…273)

The Payments Mind template already carries the payments skill, so no owner
adds anything. Its blurb names the quote: with "(cannot send them yet)" a
try-out Mind with ~20 skills refused from the skill list without calling the
tool (Chrome, 12 Nov).

Tests: test:unit 177/177; skills-crosschain (live, a 14-skill Mind, fake
1Click) 9/9 over 3 runs; bun run test 315/317 (autopilot timing and one
calendar-local-times run; both pass alone, 7/7 and 3/3); Chrome e2e on a
local stack with the real 1Click: Base USDC and Solana USDT quotes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
1Click signs every quote, dry ones too. The result now carries proof:
{ signedBy1Click, signature, quoteHash, publicKey }, checked with the
official verifyQuoteSignature from @defuse-protocol/one-click-sdk-typescript
0.1.26 (pinned). The playbook has the Mind say so in plain words after the
result, or that the signature could not be checked.

Tests: test:unit 178/178 (a recorded real signed quote verifies, a changed
amountOut does not); skills-crosschain live 9/9 over 3 runs (the signed
answer is called signed, the unsigned one never verified); Chrome e2e on a
local stack against the real 1Click: proof question in English and
Indonesian answered with the hash, key and signature.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
#273)

Asked to list the hash and signature, the model dropped characters (a
three-character gap in the 88-character signature; the hash missing or wrong
in 3 of 6 runs), so a shown proof would not verify. It now says NEAR Intents
signed the numbers and the signature checked out, and leaves the exact values
to the app, which shows them from the tool result.

Tests: skills-crosschain live 9/9 over 3 runs (fails on any proof-like string
that is not exactly the tool's); Chrome e2e: a plain request got the proof
without being asked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
rpc.testnet.near.org answered "THIS ENDPOINT IS DEPRECATED! STOP USING IT
NOW!" instead of results on and off (12 Nov), failing near_view_account
and every test that reads an account (11 in one full run).
https://test.rpc.fastnear.com is listed at docs.near.org/api/rpc/providers;
NEAR_RPC_URL still overrides it.

Tests: test:unit 178/178; bun run test 317/318 with the new default (one
workflow test where the model tried send_payment, which a workflow doesn't
have: ToolNotFoundError, nothing paid; 5/5 on this branch and 5/5 with
main's playbook afterwards).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
@Lexirieru
Lexirieru merged commit 7ccfc39 into main Nov 12, 2026
1 check passed
@Lexirieru

Copy link
Copy Markdown
Contributor Author

Merged with Axel's approval; main deploys to the hosted demo after its CI.

@AncungAulia here's what we built today and how to try it on https://app.hellonear.xyz once it's live (James posts the deploy here):

What it is

  • A Payments Mind can now quote a stablecoin payment from NEAR to another chain through NEAR Intents (1Click API). It shows what the recipient would get, the cost and the time.
  • It's a preview only. Nothing is sent: NEAR Intents is mainnet only and our wallets are testnet, and the Mind says so.
  • Every quote is signed by NEAR Intents. The engine checks that signature with their official SDK, and the Mind says it checked out.
  • The skill is in the Payments Mind template already. A General Assistant doesn't have it and will say so (that's right).

How to test

  1. Make a new Mind from the Payments Mind template (a try-out works).
  2. Try these prompts, each in a fresh chat:
    • Send 10 USDC to 0x8ba1f109551bD432803012645Ac136ddd64DBA72 on Base.
    • Kirim 25 USDT ke 7EcDhSYGxXyscszYEp35KHN8vvw3svAuLKTzXwCFLtV di Solana.
    • How much would 50 USDC to 0x8ba1f109551bD432803012645Ac136ddd64DBA72 on Arbitrum be?
    • Can you prove the quote really comes from NEAR Intents? (after one of the above)
    • Pay 0.01 NEAR to alice.testnet. (must still be a normal send_payment approval card, not a quote)
  3. What to check:
    • The step "Used a tool" is crosschain_quote.
    • The reply shows the amount received, the cost and the seconds, and says nothing was sent.
    • It says NEAR Intents signed it.
    • No approval card and no payment for the cross-chain ones.
  4. If the Mind writes out a long hash or signature, check it against the tool result. It shouldn't retype them; tell me if it does and they differ.

FE pieces (yours, optional before the freeze)

  • A small card on tool.result of crosschain_quote: amount → received on to.chain, cost, seconds, "Preview only, nothing sent", and a "Signed by NEAR Intents" line that opens proof.quoteHash, proof.publicKey and proof.signature straight from the result.
  • Words for runs/data/tools.ts: crosschain_quote: { doing: "Getting a cross-chain quote", done: "Got a cross-chain quote", orb: "searching", node: "Cross-chain quote" }.

Next: #277. "Paste the quote in TEE Explorer" will open the report already verified, with no pasting. I'm starting the backend route now; you'll get a URL to open from the link.

@Lin1er the engine's default NEAR RPC is now https://test.rpc.fastnear.com (the old one answered "DEPRECATED"). Nothing to change in engine.env unless NEAR_RPC_URL is set there to the old endpoint.

@Lin1er

Lin1er commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Live on the hosted demo: main 7ccfc39 (automatic deploy after the merge).

  • Before: 5ff407c, and the box matched git at that revision. CI: passed: test.
  • GET /v1/health → {"ok":true,"engine":true,"revision":"7ccfc39"}. No rollback.
  • Rollback target: 5ff407c (/opt/hellonear/release-old).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants