Track 3 · Programmable2 of 4

AI & the web, on-chain

How an XChain contract can ask a question (an HTTPS endpoint or an AI model) and get back an answer the whole network agrees on.

Blockchains are deterministic; AI models and web APIs are not. XChain bridges that gap with attestation: a contract asks a question, validators answer it independently, and the network must agree before the answer is written on-chain.

Contract asks a question (web or AI)
🌐 HTTPS🤖 AI🤖 AI
staked validators each look it up independently
They agree → the answer is written on-chain
Your callback runs with the verified answer

Why this is normally impossible

A smart contract has to reach the same result on every node, forever. If a contract simply called a web API or an AI model directly, two nodes could get different answers and the shared ledger would split in two. That's why no deterministic blockchain can safely use live web or AI data inside its rules.

Make the answer itself consensus

XChain's fix is to make the answer something the network agrees on. Instead of one node fetching, a set of staked validators each fetch independently and converge on a single result. That agreed answer is recorded on-chain as a fact every node replays identically. The contract poses the question with one call and names a method to run when the answer comes back.

Two kinds of questions

  • The web: fetch an HTTPS URL. Validators must return byte-for-byte identical responses, so this fits stable, structured endpoints (prices, scores, official feeds).
  • AI: prompt a governance-approved AI model (the approved list is set by validator governance and can change over time). Because model outputs are never byte-identical, a separate judge model decides whether the validators' answers mean the same thing.

How sure do you need to be?

You choose the redundancy: 1 validator is a cheap single attestation with no consensus round; 3 or 5 require multiple validators to agree. You also set a deadline, measured in blocks.

It always resolves

If the validators agree, your contract's callback fires with the answer. If they can't agree by the deadline, the protocol synthesizes an expiry and fires the callback with a status of expired. A contract is never left hanging, waiting forever on an answer that didn't arrive.

What you can build

Judge a contest with an LLM, settle a prediction market from an official source, react to a real-world event, or moderate submissions. One tip: for anything that changes minute to minute, fetch a web endpoint rather than asking a model. AI models have knowledge cutoffs and don't know today's news.

Open the wallet ← All topics