UTXO-based Layer-1 Tokens on Bitcoin SV

Improving upon our previous primitive token solution, we devise an innovative way to store tokens in Unspent Transaction Outputs (UTXOs), same as storing native bitcoins.

Overview

Inside each UTXO, there are two parts associated with tokens as state of the token contract:

Tokens in a UTXO are transferred by signing using the private key corresponding to the public key, just like normal bitcoin transfers.

Split Tokens

One token UTXO can be split into multiple UTXOs. This is mostly used to send tokens to others while returning the change. Below is an example of splitting it into two. The total numbers of tokens are conserved after the split, i.e., x0 + x1 + y0 + y1 = x + y.

Split a Token UTXO into two

The relevant code is listed below with self-explanatory comments inline.

Split

Merge Tokens

Merge two Token UTXOs into one

Multiple token UTXOs can be combined into a single one. This can be used to combine small-sum tokens to suffice for a large-sum transfer. Below is an example of combining two token UTXOs. Again, the total numbers of tokens are conserved after the merge. Besides, we ensure x = x0 + x1 and y = y0 + y1.

The relevant code is listed below.

Merge two Token UTXOs into one

Combination

Combing Split and Merge Operations

Once we can split and merge token UTXOs, we can do arbitrary token transfers by combining them, same as multiple inputs and outputs in a normal bitcoin transfer transaction.

Demo

Here is code to deploy the token contract, split the tokens, and merge them back.

Issue Tokens

100 tokens are issued: 10 (0x0a in hex) + 90 (0x5a in hex).

Split Tokens

The UTXO of 100 tokens are split into two UTXOs: one containing 70 (0x46) tokens, the other 30 (0x1e).

Merge Tokens

The two UTXOs above are combined into a single UTXO.

Summary

There are many advantages of the UTXO-based tokenization approach.

We have only shown the basics of UTXO-based tokenization, which can be extended for a practical token solution. Some extensions are listed below:

sCrypt Inc (https://scrypt.io) is a company with a mission to provide integrated on-chain smart contracting solutions using the original BitCoin Protocol on BSV