Value

Value represents an amount of fungible tokens on a universe chain and is associated with a predefined set of materials on the Previous chain. This allows fungible tokens to be programmable on both set contracts and kind contracts.

To understand how a Value element functions within the protocol, imagine a gift card as an object composed of two elements: a Value element representing the amount of a token, and a Material element representing the card's background image.

The set contract acts as a vault, holding the specified amount of tokens in the Value element and ensuring they are owned by the object (meaning whoever owns the object can withdraw or consume the tokens). The kind contract can read the amount of tokens, load materials such as the token symbol or icon images from the Value element, and generate a new version of the card's image whenever the Value element is updated.

For a fungible token to be used within the protocol, it must be registered in the token registry. When a token is registered, information such as the token standard, contract address, and associated hash of the materials must be provided.

Representation

A Value has the following structure:

#![allow(unused)]
fn main() {
pub struct Value {
  token_std: u8,
  token_index: u56,
  amount: u192,
}
}

Field Descriptions

Size (bytes)FieldTypeDescription
1token_stdu8The token standard.
7token_indexu56A unique index assigned by the token registry under the token standard.
24amountu192The amount of the token represented.

Token Standards

At genesis, the supported token standards for value elements are:

StandardValueDescription
TOKEN_STD_NATIVE1Native token of the universe chain.
TOKEN_STD_202ERC-20-like tokens.

Additional token standards can be registered to support more types of tokens.

Limitations

The protocol allocates 192 bits to the amount field, allowing a maximum amount of 2^192 - 1 to be represented. While this accommodates most use cases, tokens with higher decimals may face an upper bound limitation.