Skip to main content

Asset Scripts

Here is where the technical protocol-ly stuff starts.

The following sections assume that you are familiar with script andtransactions.

We do not endorse any of the assets shown in examples.

There are 4 types of asset transfer scripts and 3 types of asset tag scripts. All asset scripts must be in a VOUT with a YERB value of 0.

If you are looking to use this as a guide to parse the yerbas chain, please see a note at the end of this section.

New asset script

New asset scripts are used to transfer an amount of an asset into and address during an asset create as well as associate metadata with the created asset.

Script portionNumber of bytes
Standard vout script (P2PKH)Var bytes
OP_YERB_ASSET (C0)1 byte
Length of the asset data (OP_PUSH) (Not including OP_DROP)1 or 2 bytes
'yerb' in ascii (72766E)3 bytes
Asset script type 'q' (71)1 byte
Length of asset name (OP_PUSH)1 byte
Asset name in asciiVar bytes
Amount in sats (little endian)8 bytes
Divisions (00-08)1 byte
Reissuability (00-01)1 byte
Has associated data (00-01)1 byte
Associated data (Optional; only if previous byte is 01)0x12 and 0x20 if IPFS data in which case API will encode/decode as IPFS content identifier 32 bytes of user defined data
OP_DROP (75)1 byte

On chain example: 8eefce8d264d723b6b8f3cf87bcb400a009d01c2771f94e5cc07af252851aa96 VOUT 3

Ownership asset script

Ownership asset scripts are used in tandem with a new asset script if the new asset has an associated ownership asset. Notice how ownership assets have no extra information, not even an amount.

Script portionNumber of bytes
Standard vout script (P2PKH)Var bytes
OP_YERB_ASSET (C0)1 byte
Length of the asset data (OP_PUSH) (Not including OP_DROP)1 or 2 bytes
'yerb' in ascii (72766E)3 bytes
Asset script type 'o' (6F)1 byte
Length of asset name (OP_PUSH)1 byte
Asset name in asciiVar bytes
OP_DROP (75)1 byte

On chain example: 8eefce8d264d723b6b8f3cf87bcb400a009d01c2771f94e5cc07af252851aa96 VOUT 2

Reissue asset script

Reissue asset scripts are used to change an asset's metadata. If the amount is not zero, that amount of the asset is created for the pubkey in the standard script.

Script portionNumber of bytes
Standard vout script (P2PKH)Var bytes
OP_YERB_ASSET (C0)1 byte
Length of the asset data (OP_PUSH) (Not including OP_DROP)1 or 2 bytes
'yerb' in ascii (72766E)3 bytes
Asset script type 'r' (72)1 byte
Length of asset name (OP_PUSH)1 byte
Asset name in asciiVar bytes
Amount in sats (little endian) (Amount to add into circulation)8 bytes
Divisions (00-08) (FF for unchanged; can only increase)1 byte
Reissuability (00-01)1 byte
Associated data (Optional; only if associating new data)1 type byte, 1 length byte, 32 bytes user data
OP_DROP (75)1 byte

On chain example: b9d3ba355acbf58e44e893dccbcad06a10af88727adc340eeacd10d11b026f52 VOUT 3

Transfer asset script

Transfer asset scripts are used to transfer an amount of an asset to another address. If transfering an ownership asset, use 100,000,000 (00:E1:F5:05:00:00:00:00) for the sat value.

Script portionNumber of bytes
Standard vout script (P2PKH)Var bytes
OP_YERB_ASSET (C0)1 byte
Length of the asset data (OP_PUSH) (Not including OP_DROP)1 or 2 bytes
'yerb' in ascii (72766E)3 bytes
Asset script type 't' (74)1 byte
Length of asset name (OP_PUSH)1 byte
Asset name in asciiVar bytes
Amount in sats (little endian)8 bytes
Associated data (Optional; only if a broadcast)1 type byte, 1 length byte, 32 bytes user data
OP_DROP (75)1 byte

On chain example: bae95f349f15effe42e75134ee7f4560f53462ddc19c47efdd03f85ef4ab8f40 VOUT 0

Null asset tag script

Dictates if an address is qualified for a restricted asset.

If the asset is a qualifier, a flag of 1 denotes a qualification. A flag of 0 denotes a revocation.

If the asset is a restricted asset, a flag of 1 denotes blacklisting the address. A flag of 0 denotes unblacklisting the address.

Script portionNumber of bytes
OP_YERB_ASSET (C0)1 byte
Length of the pubkey h160 (OP_PUSH)1 byte
Pubkey h16020 bytes
Length of the asset portion (OP_PUSH)1 byte
Length of the asset name (OP_PUSH)1 byte
Qualifier or restricted asset nameVar bytes
Flag (00-01)1 byte

On chain example: 4ea3369ef6fb57fc26e176ad5903d4684a8c64f641aa0e1f02e5c7428609e060 VOUT 1

Verifier asset tag script

This script must be sent with a new asset script or a reissue asset script for a restricted asset. It associates qualifiers with the restricted asset.

An asset name portion of 'true' in ascii is the default to denote no associated qualifiers.

Script portionNumber of bytes
OP_YERB_ASSET (C0)1 byte
OP_RESERVED (50)1 byte
Length of the asset portion (OP_PUSH)1 byte
Length of the qualifier name(s) (OP_PUSH)1 byte
Qualifier name(s) (joined with & in ascii)Var bytes

On chain example: 477a0b2214475d11e316524b500e29837c6763fec256594c2ca7aa369b15888b VOUT 2

Global restriction asset tag script

If the flag is 1, this stops all movement of the restricted asset. A flag of 0 re-enables movement.

Script portionNumber of bytes
OP_YERB_ASSET (C0)1 byte
OP_RESERVED (50)1 byte
OP_RESERVED (50)1 byte
Length of the asset portion (OP_PUSH)1 byte
Length of the asset name (OP_PUSH)1 byte
Restricted asset nameVar bytes
Flag (00-01)1 byte

On chain example: 2fc0bb7e3a33d12ca08f72add0effc3d059cf63382bebcad96e8923e91c3c537 VOUT 2


**Chain parsing note**

Just like the pirate by-laws, the OP_PUSH after OP_YERB_ASSET can be seen more as a suggestion rather than a rule-of-thumb. Currently nodes accept assets based on whether or not the ‘yerb’ is within 1 or 2 bytes after OP_YERB_ASSET instead of actually reading the OP_PUSH after OP_YERB_ASSET. Because of this, there are some transactions on the chain that have non-standard bytes after OP_YERB_ASSET. (Including lengths that are greater or less than the asset data or bytes that are greater than OP_PUSHDATA4).

If you only want to track ‘good’ transactions you can ignore these, as the vast majority of transactions follow proper serialization protocols. However, these malformed transactions are in fact ‘valid’ outpoints (for now) and if you want an all-encompassing tracking of the chain, you will need to check for these edge cases.

See here for an example of a full chain parsing or here for a best-effort parsing.