Elements
Elements are the fundamental components that make up objects in the Previous Network.
An object can have zero to sixteen elements. Each element is a 32-byte length data and can be of the following types: material, value, artifact, or datum.
Material
Material elements are 256-bit hashes of preimages used by an object.
These materials must be added to the Previous chain before they can be utilized. They can be loaded and processed in the kind contract on the Previous chain.
Value
Value elements represent fungible tokens on the universe chain.
A value element is a tuple of several unsigned integers. The first item in the tuple is always a uint8
indicating the token standard; the other items are interpreted depending on the token standard. Items of the tuple are big-endian encoded and concatenated to make the 32-byte payload.
Value tokens must be registered at the Token Registry before they can be used.
The fungible token standards currently supported are:
- TOKEN_STD_NATIVE: for native tokens
- TOKEN_STD_20: for ERC-20-like tokens
Native Values
Value elements with token standard TOKEN_STD_NATIVE
are in the form of (token_std, amount):
item | size | meaning |
---|---|---|
token_std | uint8 | Token standard |
amount | uint248 | The amount of token held by this object |
ERC-20 Values
Value elements with token standard other than TOKEN_STD_NATIVE
are in the form of (token_std, token_index, amount):
item | size | meaning |
---|---|---|
token_std | uint8 | Token standard |
token_index | uint56 | The index of token at the registry |
amount | uint192 | The amount of the token held by this object |
Limitations
The maximum amount of a token that can be represented by the value element is limited by the size of the amount
field. For native tokens, this limit is 2^248 - 1
, and for ERC-20 tokens, it is 2^192 - 1
.
Artifact
Artifact elements represent non-fungible tokens (NFTs) on the universe chain.
An artifact element is a tuple of several unsigned integers. The first item in the tuple is always a uint8
indicating the token standard; the other items are interpreted depending on the token standard. Items of the tuple are big-endian encoded and concatenated to make the 32-byte payload.
The token standards currently supported are:
- TOKEN_STD_721: ERC-721-like tokens
- TOKEN_STD_1155: ERC-1155-like tokens
Non-fungible tokens must be registered at the Token Registry before they can be used.
ERC-721 Artifacts
Artifact elements with token standard TOKEN_STD_721
are in the form of (token_std, token_index, id, padding):
item | size | meaning |
---|---|---|
token_std | uint8 | Token standard |
token_index | uint56 | The index of token at the registry |
id | uint64 | The unique identifier of the NFT |
padding | uint128 | Unused space |
ERC-1155 Artifacts
Artifact elements with token standard TOKEN_STD_1155
are in the form of (token_std, token_index, id, amount):
item | size | meaning |
---|---|---|
token_std | uint8 | Token standard |
token_index | uint56 | The index of token at the registry |
id | uint64 | The unique identifier of the NFT |
amount | uint128 | The amount of the token held by this object |
Limitations
The id
of an artifact token is limited to [1, 2^64 - 1]
, and the amount
of an artifact token (if any) is limited to [0, 2^128 - 1
.
Datum
Datum elements can be used to store various forms of data. They can be accessed in the contract implementation of a set on the universe chain or in the kind contract on the Previous chain.