mirror of
https://github.com/bitcoinbook/bitcoinbook
synced 2025-02-02 19:01:13 +00:00
CH14: remove most of Colored Coined text
This commit is contained in:
parent
c21794b44f
commit
372ef38fdf
247
ch12.asciidoc
247
ch12.asciidoc
@ -189,252 +189,9 @@ More recent implementations of colored coins use the +OP_RETURN+ script
|
|||||||
opcode to store metadata in a transaction, in conjunction with external
|
opcode to store metadata in a transaction, in conjunction with external
|
||||||
data stores that associate the metadata to specific assets.
|
data stores that associate the metadata to specific assets.
|
||||||
|
|
||||||
((("Open Assets")))The two most prominent implementations of colored
|
=== RGB
|
||||||
coins today are http://www.openassets.org/[_Open Assets_] and
|
|
||||||
http://coloredcoins.org[_Colored Coins by Colu_]. These two systems use
|
|
||||||
different approaches to colored coins and are not compatible. Colored
|
|
||||||
coins created in one system cannot be seen or used in the other system.
|
|
||||||
|
|
||||||
==== Using Colored Coins
|
//FIXME
|
||||||
|
|
||||||
Colored coins are created, transferred, and generally viewed in special
|
|
||||||
wallets that can interpret the colored coins protocol metadata attached
|
|
||||||
to bitcoin transactions. Special care must be taken to avoid using a
|
|
||||||
colored-coin–related key in a regular bitcoin wallet, as the
|
|
||||||
regular wallet may destroy the metadata. Similarly, colored coins should
|
|
||||||
not be sent to addresses managed by regular wallets, but only to
|
|
||||||
addresses that are managed by wallets that are colored-coin-aware. Both
|
|
||||||
Colu and Open Assets systems use special colored-coin addresses to
|
|
||||||
mitigate this risk and to ensure that colored coins are not sent to
|
|
||||||
unaware wallets.
|
|
||||||
|
|
||||||
Colored coins are also not visible to most general-purpose blockchain
|
|
||||||
explorers. Instead, you must use a colored-coins explorer to interpret
|
|
||||||
the metadata of a colored coins transaction.
|
|
||||||
|
|
||||||
An Open Assets-compatible wallet application and blockchain explorer can
|
|
||||||
be found at https://www.coinprism.info[coinprism].
|
|
||||||
|
|
||||||
A Colu Colored Coins-compatible wallet application and blockchain
|
|
||||||
explorer can be found at http://coloredcoins.org/explorer/[Blockchain
|
|
||||||
Explorer].
|
|
||||||
|
|
||||||
A Copay wallet plug-in can be found at
|
|
||||||
http://coloredcoins.org/colored-coins-copay-addon/[Colored Coins Copay
|
|
||||||
Addon].
|
|
||||||
|
|
||||||
==== Issuing Colored Coins
|
|
||||||
|
|
||||||
Each of the colored coins implementations has a different way of
|
|
||||||
creating colored coins, but they all provide similar functionality. The
|
|
||||||
process of creating a colored coin asset is called _issuance_. An
|
|
||||||
initial transaction, the _issuance transaction_ registers the asset on
|
|
||||||
the bitcoin blockchain and creates an _asset ID_ that is used to
|
|
||||||
reference the asset. Once issued, assets can be transferred between
|
|
||||||
addresses using _transfer transactions_.
|
|
||||||
|
|
||||||
Assets issued as colored coins can have multiple properties. They can be
|
|
||||||
_divisible_ or _indivisible_, meaning that the amount of asset in a
|
|
||||||
transfer can be an integer (e.g., 5) or have decimal subdivision (e.g.,
|
|
||||||
4.321). Assets can also have _fixed issuance_, meaning a certain amount
|
|
||||||
are issued only once, or can be _reissued_, meaning that new units of
|
|
||||||
the asset can be issued by the original issuer after the initial
|
|
||||||
issuance.
|
|
||||||
|
|
||||||
Finally, some colored coins enable _dividends_, allowing the
|
|
||||||
distribution of bitcoin payments to the owners of a colored coin asset
|
|
||||||
in proportion to their ownership.
|
|
||||||
|
|
||||||
==== Colored Coins Transactions
|
|
||||||
|
|
||||||
The metadata that gives meaning to a colored coin transaction is usually
|
|
||||||
stored in one of the outputs using the +OP_RETURN+ opcode. Different
|
|
||||||
colored coins protocols use different encodings for the content of the
|
|
||||||
+OP_RETURN+ data. The output containing the +OP_RETURN+ is called the
|
|
||||||
_marker output_.
|
|
||||||
|
|
||||||
The order of the outputs and position of the marker output may have
|
|
||||||
special meaning in the colored coins protocol. In Open Assets, for
|
|
||||||
example, any outputs before the marker output represent asset issuance.
|
|
||||||
Any outputs after the marker represent asset transfer. The marker output
|
|
||||||
assigns specific values and colors to the other outputs by referencing
|
|
||||||
their order in the transaction.
|
|
||||||
|
|
||||||
In Colored Coins (Colu), by comparison, the marker output encodes an
|
|
||||||
opcode that determines how the metadata is interpreted. Opcodes 0x01
|
|
||||||
through 0x0F indicate an issuance transaction. An issuance opcode is
|
|
||||||
usually followed by an asset ID or other identifier that can be used to
|
|
||||||
retrieve the asset information from an external source (e.g.,
|
|
||||||
bittorrent). Opcodes 0x10 through 0x1F represent a transfer
|
|
||||||
transaction. Transfer transaction metadata contain simple scripts that
|
|
||||||
transfer specific amounts of assets from inputs to outputs, by reference
|
|
||||||
to their index. Ordering of inputs and outputs is therefore important in
|
|
||||||
the interpretation of the script.
|
|
||||||
|
|
||||||
If the metadata is too long to fit in +OP_RETURN+, the colored coins
|
|
||||||
protocol may use other "tricks" to store metadata in a transaction.
|
|
||||||
Examples include putting metadata in a redeem script, followed by
|
|
||||||
+OP_DROP+ opcodes to ensure the script ignores the metadata. Another
|
|
||||||
mechanism used is a 1-of-N multisig script where only the first public
|
|
||||||
key is a real public key that can spend the output and subsequent "keys"
|
|
||||||
are replaced by encoded metadata.
|
|
||||||
|
|
||||||
In order to correctly interpret the metadata in a colored coins
|
|
||||||
transaction you must use a compatible wallet or block explorer.
|
|
||||||
Otherwise, the transaction looks like a "normal" bitcoin transaction
|
|
||||||
with an +OP_RETURN+ output.
|
|
||||||
|
|
||||||
As an example, I created and issued a MasterBTC asset using colored
|
|
||||||
coins. The MasterBTC asset represents a voucher for a free copy of this
|
|
||||||
book. These vouchers can be transferred, traded, and redeemed using a
|
|
||||||
colored coins-compatible wallet.
|
|
||||||
|
|
||||||
For this particular example, I used the wallet and explorer at
|
|
||||||
http://coinprism.info/[_https://coinprism.info_], which uses the Open
|
|
||||||
Assets colored coins protocol.
|
|
||||||
|
|
||||||
<<the_issuance_transaction_as_viewed_on_coinprismio>> shows the issuance
|
|
||||||
transaction using the Coinprism block explorer:
|
|
||||||
|
|
||||||
https://www.coinprism.info/tx/10d7c4e022f35288779be6713471151ede967caaa39eecd35296aa36d9c109ec[https://www.coinprism.info/tx/10d7c4e022f35288779be6713471151ede967caaa39eecd35296aa36d9c109ec])
|
|
||||||
|
|
||||||
[[the_issuance_transaction_as_viewed_on_coinprismio]]
|
|
||||||
.The issuance transaction as viewed on coinprism.info
|
|
||||||
image::images/mbc2_1201.png[The Issuance Transaction - as viewed on coinprism.info]
|
|
||||||
|
|
||||||
As you can see, coinprism shows the issuance of 20 units of "Free copy
|
|
||||||
of Mastering Bitcoin," the MasterBTC asset, to a special colored coin
|
|
||||||
address:
|
|
||||||
|
|
||||||
----
|
|
||||||
akTnsDt5uzpioRST76VFRQM8q8sBFnQiwcx
|
|
||||||
----
|
|
||||||
|
|
||||||
[WARNING]
|
|
||||||
====
|
|
||||||
Any funds or colored assets sent to this address will be lost forever.
|
|
||||||
Do not send value to this example address!
|
|
||||||
====
|
|
||||||
|
|
||||||
((("transaction IDs (txid)")))The transaction ID of the issuance
|
|
||||||
transaction is a "normal" bitcoin transaction ID.
|
|
||||||
<<the_issuance_transaction_on_a_block>> shows that same transaction in a
|
|
||||||
block explorer that doesn't decode colored coins. We'll use
|
|
||||||
_blockchain.info_:
|
|
||||||
|
|
||||||
https://blockchain.info/tx/10d7c4e022f35288779be6713471151ede967caaa39eecd35296aa36d9c109ec[https://blockchain.info/tx/10d7c4e022f35288779be6713471151ede967caaa39eecd35296aa36d9c109ec]
|
|
||||||
|
|
||||||
[[the_issuance_transaction_on_a_block]]
|
|
||||||
.The issuance transaction on a block explorer that doesn't decode colored coins
|
|
||||||
image::images/mbc2_1202.png[The Issuance Transaction - on a block explorer that doesn't decode colored coins]
|
|
||||||
|
|
||||||
As you can see, _blockchain.info_ doesn't recognize this as a colored
|
|
||||||
coins transaction. In fact, it marks the second output with "Unable to
|
|
||||||
decode output address" in red letters.
|
|
||||||
|
|
||||||
If you select "Show scripts & coinbase" on that screen, you can see
|
|
||||||
more detail about the transaction
|
|
||||||
(<<the_scripts_in_the_issuance_transaction>>).
|
|
||||||
|
|
||||||
[[the_scripts_in_the_issuance_transaction]]
|
|
||||||
.The scripts in the issuance transaction
|
|
||||||
image::images/mbc2_1203.png[The scripts in the Issuance Transaction]
|
|
||||||
|
|
||||||
Once again, _blockchain.info_ doesn't understand the second output. It
|
|
||||||
marks it with "Strange" in red letters. However, we can see that some of
|
|
||||||
the metadata in the marker output is human-readable:
|
|
||||||
|
|
||||||
----
|
|
||||||
OP_RETURN 4f41010001141b753d68747470733a2f2f6370722e736d2f466f796b777248365559
|
|
||||||
(decoded) "OA____u=https://cpr.sm/FoykwrH6UY
|
|
||||||
----
|
|
||||||
|
|
||||||
Let's retrieve the transaction using +bitcoin-cli+:
|
|
||||||
|
|
||||||
----
|
|
||||||
$ bitcoin-cli decoderawtransaction `bitcoin-cli getrawtransaction 10d7c4e022f35288779be6713471151ede967caaa39eecd35296aa36d9c109ec`
|
|
||||||
----
|
|
||||||
|
|
||||||
Stripping out the rest of the transaction, the second output looks like
|
|
||||||
this:
|
|
||||||
|
|
||||||
[role="pagebreak-before"]
|
|
||||||
[source,json]
|
|
||||||
----
|
|
||||||
{
|
|
||||||
"value": 0.00000000,
|
|
||||||
"n": 1,
|
|
||||||
"scriptPubKey": "OP_RETURN 4f41010001141b753d68747470733a2f2f6370722e736d2f466f796b777248365559"
|
|
||||||
|
|
||||||
}
|
|
||||||
----
|
|
||||||
|
|
||||||
The prefix +4F41+ represents the letters "OA", which stands for "Open
|
|
||||||
Assets" and helps us identify that what follows is metadata defined by
|
|
||||||
the Open Assets protocol. The ASCII-encoded string that follows is a
|
|
||||||
link to an asset definition:
|
|
||||||
|
|
||||||
----
|
|
||||||
u=https://cpr.sm/FoykwrH6UY
|
|
||||||
----
|
|
||||||
|
|
||||||
((("", startref="color12")))((("", startref="BCAcoins12")))If we
|
|
||||||
retrieve this URL, we get a JSON-encoded asset definition, as shown
|
|
||||||
here:
|
|
||||||
|
|
||||||
[source,json]
|
|
||||||
----
|
|
||||||
{
|
|
||||||
"asset_ids": [
|
|
||||||
"AcuRVsoa81hoLHmVTNXrRD8KpTqUXeqwgH"
|
|
||||||
],
|
|
||||||
"contract_url": null,
|
|
||||||
"name_short": "MasterBTC",
|
|
||||||
"name": "Free copy of \"Mastering Bitcoin\"",
|
|
||||||
"issuer": "Andreas M. Antonopoulos",
|
|
||||||
"description": "This token is redeemable for a free copy of the book \"Mastering Bitcoin\"",
|
|
||||||
"description_mime": "text/x-markdown; charset=UTF-8",
|
|
||||||
"type": "Other",
|
|
||||||
"divisibility": 0,
|
|
||||||
"link_to_website": false,
|
|
||||||
"icon_url": null,
|
|
||||||
"image_url": null,
|
|
||||||
"version": "1.0"
|
|
||||||
}
|
|
||||||
----
|
|
||||||
|
|
||||||
=== Counterparty
|
|
||||||
|
|
||||||
((("blockchain applications",
|
|
||||||
"Counterparty")))((("Counterparty")))((("smart contracts")))((("Ethereum
|
|
||||||
Virtual Machine (EVM)")))((("extrinsic asset management")))((("virtual
|
|
||||||
asset management")))Counterparty is a protocol layer built on top of
|
|
||||||
bitcoin. The Counterparty protocol, similar to colored coins, offers the
|
|
||||||
ability to create and trade virtual assets and tokens. In addition,
|
|
||||||
Counterparty offers a decentralized exchange for assets. Counterparty is
|
|
||||||
also implementing smart contracts, based on the Ethereum Virtual Machine
|
|
||||||
(EVM).
|
|
||||||
|
|
||||||
Like the colored coins protocols, Counterparty embeds metadata in
|
|
||||||
bitcoin transactions, using the +OP_RETURN+ opcode or 1-of-N
|
|
||||||
multisignature addresses that encode metadata in the place of public
|
|
||||||
keys. Using these mechanisms, Counterparty implements a protocol layer
|
|
||||||
encoded in bitcoin transactions. The additional protocol layer can be
|
|
||||||
interpreted by applications that are Counterparty-aware, such as wallets
|
|
||||||
and blockchain explorers, or any application built using the
|
|
||||||
Counterparty libraries.
|
|
||||||
|
|
||||||
((("digital ownership")))Counterparty can be used as a platform for
|
|
||||||
other applications and services, in turn. For example, Tokenly is a
|
|
||||||
platform built on top of Counterparty that allows content creators,
|
|
||||||
artists, and companies to issue tokens that express digital ownership
|
|
||||||
and can be used to rent, access, trade, or shop for content, products,
|
|
||||||
and services. Other applications leveraging Counterparty include games
|
|
||||||
(Spells of Genesis) and grid computing projects (Folding Coin).
|
|
||||||
|
|
||||||
More details about Counterparty can be found at https://counterparty.io.
|
|
||||||
The open source project can be found at
|
|
||||||
https://github.com/CounterpartyXCP[].
|
|
||||||
|
|
||||||
[[state_channels]]
|
[[state_channels]]
|
||||||
=== Payment Channels and State Channels
|
=== Payment Channels and State Channels
|
||||||
|
Loading…
Reference in New Issue
Block a user