Thursday, 1 February 2018

Bitcoin transaction and Open Asset protocol

In Bitcoin transaction, it can have multiple vin and vout. In vout, it contains bitcoin script. The script can use PKSH or P2PKH as recipient. In bitcoin script, the OP_RETURN contains metadata payload.

In Open Asset Protocol, the OP_RETURN metadata is used to store Open Asset asset id and quantity (see https://en.bitcoin.it/wiki/Colored_Coins#Open_Assets). The encoding is based on LEB128. LEB128 is a compression algorithm to store a large number of small integers.

Now, the OP_RETURN accepts up to 83 bytes: https://github.com/bitcoin/bitcoin/blob/master/src/script/standard.h#L34.

The OA metadata format is shown as below:

OAP marker: 2 bytes,
version number: 2 bytes,
Asset quantity count (varint): minimum 1 byte.
Asset quantity (LED encoded): varies
Arbitrary metadata length
Arbitrary metadata

The official spec is here:
https://github.com/OpenAssets/open-assets-protocol

No comments:

Post a Comment