Experimental · Chipnet first

XO on Bitcoin Cash

XO is a template-driven contract framework for Bitcoin Cash. You describe a contract once — its roles, actions, variables and locking scripts — and the engine builds every transaction from that template. Participants coordinate through signed invitations.

This workspace hosts a runnable Chipnet demo. Phase 1 is a standalone Node script that follows the General Protocols getting-started guide; Phase 2 is a client-only browser playground.

Early development — treat it as a laboratory

The XO docs warn that minor version bumps may introduce breaking changes, that some applications may be impossible with the current stack, and that you should not use funds you are not willing to lose. The demo runs on Chipnet with a throwaway mnemonic.

The demo

Phase 1 lives in xo-demo/ in this project. It is a standalone Node package with its own dependencies; it is not part of the Nuxt build. It creates one account, imports the built-in P2PKH template, derives a receive address, and builds a 5,000-satoshi payment to a second address of the same account through an invitation.

Step 1

Create the account

npm run address prints a bchtest:… address.

Step 2

Preview the payment

npm run preview builds and signs the invitation, then prints the transaction and its JSON.

Step 3

Broadcast it

npm run broadcast repeats the flow and sends the transaction to Chipnet.

cd xo-demo
npm install
export XO_MNEMONIC="your throwaway test mnemonic"
npm run address
# fund the printed bchtest:... address with at least 10,000 sats
npm run preview
npm run broadcast

The mnemonic is read from XO_MNEMONIC. Use a throwaway BIP39 mnemonic; never use one that holds real funds. The SQLite database and .env are git-ignored.

What it exercises

  • Engine.create
  • importTemplate(p2pkhTemplate)
  • setDefaultPolicies
  • generateLockingBytecodeFromDefaultPolicy
  • listSpendableUnspentOutputs
  • createInvitation
  • appendInvitation
  • calculateChange / addChangeToInvitation
  • listOwnInputIndexes / signInvitation
  • buildInvitationTransactionFromMergedCommit
  • executeAction({ broadcastTransaction })
  • serializeInvitation

Safety rails

  • Chipnet only: the engine is created with XO_SUPPORTED_NETWORKS.chipnet.
  • Throwaway mnemonic only: the value comes from XO_MNEMONIC and is never committed.
  • Preview first: only the --broadcast flag sends the transaction.
  • Local state stays local: data/, .env and the SQLite files are git-ignored.

How XO works

The vocabulary is small. Once these seven terms click, the demo’s call order reads as a sequence rather than a pile of nouns.

Account

One mnemonic on one network. Each Engine instance opens one account.

Template

A standard description of a BCH use case: roles, actions, variables, transactions, outputs and locking scripts. The engine builds every transaction from it. The templateIdentifier is a hash of its content.

Role

A participant position in an action, such as receiver or sender.

Action

Something a role can do with a template.

Intent

The request the engine starts from: an action, output or locking script, plus the role, keys and starting values.

Invitation

Coordinates one action between participants. Each adds commits until the action has everything it needs; then any participant can execute it.

Commit

One signed addition by one participant: a role, variables, inputs, outputs, key values or unlocking bytecode. Commits only add; a later commit cannot change an earlier value.

Definitions condensed from the XO Stack “Getting Started” guide.

Built-in templates

A snapshot of the five templates shipped in @xo-cash/templates 0.0.12 (published 30 October 2026). The package is the source of truth. The demo starts with the P2PKH template; replacing it is the next experiment.

Wallet (P2PKH)

owner · receiver · sender

A standard single-factor wallet template that uses Pay-to-Public-Key-Hash locking scripts.

Starts with
receive · requestSatoshis · requestFungibleTokens · requestNonfungibleTokens
All actions
receive · requestSatoshis · requestFungibleTokens · requestNonfungibleTokens · sendSatoshis · sendFungibleTokens · sendNonfungibleTokens · burnFungibleTokens · burnNonfungibleTokens · sign · verify

Multisig Wallet (2 of 3)

firstSigner · secondSigner · thirdSigner

A 2-of-3 multisig vault that locks funds to three keys and spends them with any two signatures.

Starts with
receive
All actions
receive · sendWithFirstAndSecond · sendWithFirstAndThird · sendWithSecondAndThird

Wrapped BCH

wrapper · unwrapper · service

Convert between BCH and wBCH tokens.

Starts with
—
All actions
wrap · unwrap

Wrapped BCH (chipnet)

wrapper · unwrapper · service

Convert between BCH and wBCH tokens on the chipnet.

Starts with
—
All actions
wrap · unwrap

faucet.cash

recipient · service

A public Bitcoin Cash faucet with on-chain rate limits.

Starts with
—
All actions
claim

Template metadata verified against the published 0.0.12 package.

The flow in code

The demo’s first half is the guide’s account setup: open the account, import the template, set the default policies, and derive a receive address. The second half creates the invitation, adds the recipient output and change, signs the input, previews the transaction, and optionally broadcasts it.

import { Engine, XO_SUPPORTED_NETWORKS } from '@xo-cash/engine'
import { p2pkhTemplate } from '@xo-cash/templates'
import { hexToBin, lockingBytecodeToCashAddress } from '@bitauth/libauth'

const engine = await Engine.create('your test mnemonic', {
    network: XO_SUPPORTED_NETWORKS.chipnet,
})

const { templateIdentifier } = await engine.importTemplate(p2pkhTemplate)

await engine.setDefaultPolicies({
    change: { templateIdentifier },
    receive: { templateIdentifier },
    address: { templateIdentifier },
})

const fundingLockingBytecode = await engine.generateLockingBytecodeFromDefaultPolicy('receive')
const fundingAddress = lockingBytecodeToCashAddress({
    bytecode: hexToBin(fundingLockingBytecode),
    prefix: 'bchtest',
})

if (typeof fundingAddress === 'string') {
    throw new Error(fundingAddress)
}

console.log(fundingAddress.address)

The invitation half uses createInvitation, appendInvitation, calculateChange, addChangeToInvitation, signInvitation, and executeAction. The full script is in xo-demo/demo.mjs.

Official resources

The XO stack is developed by General Protocols. These are the canonical links from the project site and the public BCH BLAZE 2026 briefs.

Resource provenance: the two General Protocols BCH BLAZE 2026 briefs (Build With XO and Migrate To XO). We are not entering the bounties; the briefs are used as a public index of the team’s guidance.

What this page does — and does not do

  • It documents the Phase 1 demo and the XO vocabulary in one place.
  • It is static and prerendered. It holds no keys, creates no invitations and broadcasts no transactions.
  • It does not run the XO engine in your browser. Phase 2 is a client-only playground with a throwaway account, IndexedDB storage and a live Electrum WebSocket connection; it is not built yet.
  • The demo is a single-participant P2PKH send. Custom templates, multi-party invitations and a browser UI are the next experiments.