Colored Coins
Whitepaper on the concept of Colored Coins
Colored coins are a loose term for methods to represent assets other than currency on the Bitcoin blockchain. For example, they might be used to represent stock shares, votes, collectables, access tokens or smart property.
Introduction
Enhanced Padded Order-Based Coloring
EPOBC (Enhanced Padded Order-Based Coloring) is a protocol for coloring coins. It uses the sequence number field of transaction inputs for encoding, which does not increase the transaction size unlike OP_RETURN based protocols.
The color of an EPOBC colored coin is the hash of the genesis transacation it belongs to. The padding of a color coin transaction output is encoded in it's nSequence field and is used to counter the dust threshold (currently 546 satoshis). The colorvalue of a colored coin transaction output is the same as the value in satoshis minus the padding.
We can't create transaction outputs with a value of 1 satoshi forexample, But the use of padding makes it possible to transfer any colorvalue from zero and up.
Transactions
To separate transactions with colored coins we encode information in the sequence field of each transaction input. This 32 bit field is not officially used by Bitcoin and is always left as `0xFFFFFFFF` for normal transactions. EPOBC encodes information in this field with the following scheme.
| Bits | Name | Description |
|---|---|---|
| 6 | Tag | Specifies the EPOBC transaction type |
| 6 | Padding Value | The padding that is used to compensate for the dust threshold |
| 24 | Not Used |
The tag can be either 110011 to indicate a genesis transaction or 100101 to indicate a transfer transaction.
Genesis Transactions
To issue new colored coins, we must introduce them to the blockchain by creating a genesis transaction. When we issue an EPOBC color it cannot be issued again, and the amount of the color that exists will always be fixed. Some other protocols support reissuable colors (by using issuing addresses).
Transfer Transactions
If all transactions had only one input and one output it would be easy to determine the color of the output (it would be the same as the input) and tracing back to the genesis transaction would be trivial. But if we want to transfer multiple colors to multiple outputs we will need to use a coloring algorithm to determine the destination of each color in a transaction. APOBC is based on a method called order based coloring.
Coloring Algorithms
To understand the motive for coloring algorithms it's best to consider a transaction with multiple inputs and outputs. Some of the inputs are colored (we see that by looking at the nSequence field) and we need to be able to trace back to the genesis transaction that issued them. But the inputs might have different colors, and we want to know what color of coins should go to each of the outputs (or know which outputs should get uncolored coins).
A coloring algorithm is a method of determining the colors of transaction outputs given the full list of transaction inputs and outputs. The two most common methods are order based coloring (OBC) and tagging based coloring. EPOBC uses an improved version of OBC that circumvents the dust limit.