Skip to content
Developer Handbook

CashTokens

On this page

Suppose the 100,000-sat funding UTXO also carries 25 loyalty points. CashTokens can store those points alongside the BCH. The locking script still controls who can spend the UTXO. The new transaction specifies which outputs receive the points.

What tokens represent

  • Fungible tokens are interchangeable units within a category. The 25 loyalty points are fungible because each point counts the same.
  • A non-fungible token (NFT) can carry its own data, such as a ticket number. That data is its commitment.

A token category identifies which kind of points or NFTs a UTXO holds. An output can carry a fungible amount, one NFT, or both from the same category. When building a spend, assign tokens explicitly to the recipient or change so a BCH-only payment does not burn them. CashTokens specification

Read a token-bearing UTXO

Compare this token-bearing UTXO with the original P2PKH UTXO. The value is still 100,000 sats and the locking bytecode is the same. The field that held only the script now starts with a token prefix for the 25 points.

a086010000000000 3c
ef efcdab8967452301efcdab8967452301efcdab8967452301efcdab8967452301 10 19
76a914b2557abfebaf263824b75ec473fd7b3db74957ea88ac
Wire fieldDecoded value
a086010000000000valueSatoshis: 100_000n
3cCompactSize byte length, 60 bytes for prefix plus script
ef, then 32 bytesToken marker and token.category, whose display hex is 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
10 19Bitfield for fungible amount present and no NFT, followed by token.amount: 25n in CompactSize
76a914…88aclockingBytecode, the same 25-byte P2PKH script as the example

An NFT changes the flags and may add a length-prefixed commitment before the optional amount. Libauth decodes those fields into the optional output.token object. When authorizing a spend, supply the UTXO data with its tokens intact. Plain output bytes and fields · Token prefix format

Create a token category

To create the loyalty point category, spend output 0 of an earlier transaction as a genesis input. The transaction ID of that earlier transaction becomes the category ID. Follow the CashTokens genesis rules to issue the initial amount or NFTs.

Track NFT capabilities

An NFT’s capability controls what the next spend can do. An immutable NFT preserves its commitment, such as a ticket number. A mutable NFT can update it, such as the expiry date of a membership. A minting NFT can authorize new NFTs in its category. Store the capability and commitment with the category and outpoint. CashTokens consensus rules

Resolve metadata with BCMR

Bitcoin Cash Metadata Registries describe tokens using names, tickers, icons, and other off-chain information. Look up metadata by category and verify its authenticity against a registry or identity chain you trust. Treat the on-chain amount and category as the spending record even when metadata is missing. BCMR specification