Hans Schmidt :  Aug 1st 2021

hans_schm1dt@protonmail.com


Anatomy of a Ravencoin Asset Transaction Script

*Note: This document is a "work in progress". If you see errors, please enter an "Issue" on github*


This page describes the encoding of a Ravencoin Asset Script.

Asset scripts are used to create an asset, transfer an asset, modify data associated with an asset, or modify the behavior of an asset.

An asset script is always placed into one of the output structures of a transaction, with the value of that output set at value=0. Usually the asset script is appended to a bitcoin-style scriptPubKey in the output. There are, however, some asset scripts (called nullasset scripts) which are placed into an output which has no bitcoin-style scriptPubKey at all.

For more context and examples of how a complete transaction is constructed, please look HERE.


Asset Owner script

The asset owner script gives the Owner Asset to an address. The Owner Asset (represented by a NAME followed by the symbol '!') proves ownership of that NAME, which provides certain authority such as the authority to reissue assets using that NAME, to create subassets and unique assets under that NAME, and to  create restricted assets using that NAME. The Owner Asset is given as an output when a new Main_Asset (Root Asset) is created. It is also used as an input and given back as an output in any transactions which needs the Owner Asset to authorize one of the authority-requiring asset operations just described.

Description  Length 
Hex Value
OP_RVN_ASSET 1 byte
c0
Bytelength of script 1 byte
0c
Asset_type Header("rvn" in ASCII) 3 bytes
72766e
Asset_type: owner(o)=6f 1 byte
6f
Bytelength of Asset_Name 1 byte
05
Asset_Name: (root_asset!) up to 31 bytes

OP_DROP 1 byte
75





New Asset script

The New Asset script serves to create a new asset, which can be a Main_Asset (Root Asset), a Subasset, a Restricted_Asset, a Qualifier asset, or a Subqualifier asset. Metadata will also be associated with the created asset as detailed below. If the New Asset being created is a Main_Asset (Root Asset), then an Owner Asset is also created.

Description  Length 
Hex Value
OP_RVN_ASSET 1 byte
c0
Bytelength of script 1 byte
48
Asset_type Header("rvn" in ASCII) 3 bytes
72766e
Asset_type: new(q)=71 1 byte
71
Bytelength of Asset_Name 1 byte
05
Asset_Name:
root_asset, root/subasset, root#unique, $restricted_asset, #qualifier, #qualifier/#subqualifier
up to 31 bytes

8 Bytes of Little Endian hex: "Amount" of assets in satoshis 8 bytes
00743ba40b000000
Divisible-by range: (00..08) units
1 byte
08
is reissueable (01 yes: 00 no) 1 byte
01
Has userdata (01 yes: 00 no) 1 byte
01
1byte Type +1byte Length +32bytes max (usu IPFS base58 converted to hex) variable (max 34)

OP_DROP 1 byte
75

Note:

For Unique Asset:
    -Unit is always set to Zero (0)
    -Reissuable is always set to false

For Qualifier:
    -Amount is a number between 1 and 10
    -Unit is always set to Zero (0)
    -Reissuable is always set to false

For Restricted Asset:
    -Unit is always set to Zero (0)
    -Reissuable is true/false for whether additional asset quantity can be created and if the verifier string can be changed

Divisible:
    -Specifies how many decimal places the "Amount" has to the right of the decimal point. Zero means "Amount" is always an integer number of assets. Amount of eight means "Amount" varies in increments of 0.00000001 assets.




Asset Transfer script

The Asset Transfer script simply moves an asset from one address to another address. Any asset type can be transferred, but the movement of a Restricted Asset may be restricted based on the associated Verifier String, an Address Freeze, or a Global Freeze. Asset transfer scripts support the embedding of a message and a message expiry time into the transaction output.

Description  Length 
Hex Value
OP_RVN_ASSET 1 byte
c0
Bytelength of script 1 byte
38
Asset_type Header("rvn" in ASCII) 3 bytes
72766e
Asset_type: transfer(t)=74 1 byte
71
Bytelength of Asset_Name 1 byte
05
Asset_Name:
root_asset, root/subasset, root#unique, $restricted_asset, #qualifier, #qualifier/#subqualifier
up to 31 bytes

8 Bytes of Little Endian hex: Amount of assets in satoshis 8 bytes
00743ba40b000000
Bytelength of Message
1 byte
08
Message variable
01
Message Expiry Time
1 byte
01
OP_DROP 1 byte
75





Asset Reissue script

The Asset Reissue script issues an additional quantity of an asset or modifies the metadata associated with that asset. Asset Reissue requires possession of the Owner Asset, which is used as an input of the transaction containing a Reissue (to prove authority), and is returned as an output of the same transaction. Asset Reissue is also only possible if the reissue authority is indicated in the metadata of the asset, based on a choice made during the original Issue operation of the asset or during a subsequent Reissue operation. Note that during a Reissue operation, divisibility (how many decimal places to the right of the decimal point) may only be increased or kept the same, and any increase in divisibility cannot be used until after the increase has taken effect by being mined. Unique assets can never be reissued.

Description  Length 
Hex Value
OP_RVN_ASSET 1 byte
c0
Bytelength of script 1 byte
38
Asset_type Header("rvn" in ASCII) 3 bytes
72766e
Asset_type: transfer(t)=74 or new(q)=71 or owner(o)=6f 1 byte
71
Bytelength of Asset_Name 1 byte
05
Asset_Name:
root_asset, root/subasset, root#unique, $restricted_asset, #qualifier, #qualifier/#subqualifier
up to 31 bytes

8 Bytes of Little Endian hex: Amount of assets in satoshis 8 bytes
00743ba40b000000
Divisible-by range: (00..08) units
1 byte
08
is reissueable (01 yes: 00 no) 1 byte
01
Has userdata (01 yes: 00 no) 1 byte
01
1byte Type +1byte Length +32bytes max (usu IPFS base58 converted to hex) variable (max 34)

OP_DROP 1 byte
75

Note:

For Restricted Asset:
    -Unit is always set to Zero (0)
    -Reissuable is true/false for whether additional asset quantity can be created and if the verifier string can be changed




Tag/Untag Address script
(a type of nullasset script)

The Tag/Untag Address script is used to tag or untag an address using a Qualifier. This operation determines whether a particular Restricted Asset may be received by that address depending on whether or not the address satisfies the requirements of the VerifierString (a boolean of Qualifiers) associated with that Restricted Asset.

Description  Length 
Hex Value
OP_RVN_ASSET 1 byte
c0
NullAssetTxDataScript identifier
1 byte
14
Hash-160 Address
20 bytes

Bytelength of Script 1 byte
0b
Bytelength of Qualifier Name
1 byte
05
Qualifier Name (#qualifier OR #qualifier/#subqualifier) up to 31 bytes

Operation (1=Add, 0=Remove)
1 bytes
01
OP_DROP 1 byte
75





Freeze/Unfreeze Address script
(a type of nullasset script)

The Freeze/Unfreeze Address script is used to freeze or unfreeze the movements of a particular Restricted Asset at a particular address. When frozen, the specified Restricted Asset may not be transferred into or out of the specified address.

Description  Length 
Hex Value
OP_RVN_ASSET 1 byte
c0
NullAssetTxDataScript identifier
1 byte
14
Hash-160 Address
20 bytes

Bytelength of Script 1 byte
0b
Bytelength of Restricted Asset Name
1 byte
05
Restricted Asset Name ($restricted_asset) up to 31 bytes

Operation (1=Freeze, 0=Unfreeze)
1 bytes
01
OP_DROP 1 byte
75





Global Freeze/Unfreeze script
(a type of nullasset script)

The Global Freeze/Unfreeze script is used to freeze or unfreeze the movements of a particular Restricted Asset at all addresses. When frozen, the specified Restricted Asset may not be transferred into or out of any addresses.

Description  Length 
Hex Value
OP_RVN_ASSET 1 byte
c0
NullGlobalRestrictionAssetTxDataScript identifier
2 bytes
5050
Bytelength of Script 1 byte
0b
Bytelength of Restricted Asset Name
1 byte
05
Restricted Asset Name ($restricted_asset) up to 31 bytes

Operation (1=Freeze, 0=Unfreeze)
1 bytes
01
OP_DROP 1 byte
75





VerifierString Assignment script
(a type of nullasset script)

A Verifier String is a boolean expression comprised of Qualifiers and boolean operators. It is associated with a Restricted Asset and determines the qualifiers which must have tagged an address in order for that address to be allowed to receive that Restricted Asset. In a transaction in which a Restricted Asset is issued or reissued by an output New Asset script or Reissue Asset script, an additional output containing a Verifier String script is created which associates that Verifier String with that Restricted Asset. A Restricted Asset requires a Verifier Script, and the Verifier Script "true" is used when no Qualifiers are desired.

Description  Length 
Hex Value
OP_RVN_ASSET 1 byte
c0
NullAssetVerifierTxDataScript identifier
1 byte
50
1 byte
anything except 50
Bytelength of Script 1 byte
0b
Bytelength of VerifierString
1 byte
05
VerifierString up to 31 bytes

OP_DROP 1 byte
75





Asset Naming Rules

ROOT_ASSET: Root asset name valid characters are: A-Z 0-9 . _
    special characters can't be the first or last characters or repeated
OWNER: Owner asset will be the Root asset with ! appended

SUB_ASSET: Sub_asset name valid characters are: A-Z 0-9 . _
    / must be the first character. special characters can't be the first or last characters or repeated

UNIQUE: Unique name valid characters are: A-Z a-z 0-9 @ $ % & * ( ) [ ] { } _ . ? : -
    # must be the first character.

MSGCHANNEL: Message Channel name valid characters are: A-Z 0-9 _ .
    ~ must be the first character. Special characters can't be the first or last characters or repeated

VOTE: Vote name valid characters are: A-Z 0-9 _ .
    ^ must be the first character. Special characters can't be the first or last characters or repeated

QUALIFIER or SUB_QUALIFIER: Qualifier or Sub_qualifier name valid characters are: A-Z 0-9 _ .
    # must be the first character. Special characters can't be the first or last characters or repeated

RESTRICTED: Restricted name valid characters are: A-Z 0-9 _ .
    $ must be the first character. Special characters can't be the first or last characters or repeated

VerifierString: Boolean expression comprised of Qualifiers and boolean operators, up to 31 bytes in length

The names RVN, RAVEN, and RAVENCOIN are reserved

Excluding the owner tag ('!') =>
    MAX_NAME_LENGTH = 31;
    MAX_CHANNEL_NAME_LENGTH = 12;
    must have at least 3 characters
    Max VerifierString Length: 31 bytes

Copyright 2021 by Hans Schmidt