- Getting Started
- Key Concepts
- Deep Dive
- APIs, SDKs and Tools
Token-based Transaction Model
token-based transaction model for
In short, for a token-based ledger, we create a record of token id and the ownership when it is initially issued, and then
infinitely append new ownerships whenever it's transferred to others. It is a very efficient way for
Updating and querying information for a token is super fast as we have a indexed token database especially designed for this purpose.
Token-based transaction model is invented by several core team members of everiToken (Hengjin Cai, Harry Wang, Ceeji Cheng and etc.),
and is proved to work perfect for NFTs on everiToken. A related candidate IEEE article has been submitted and is being reviewed.
everiToken could be considered as a status machine that changes its status when and only when executing actions on every irreversible block.
For a blockchain based on token-based transaction model, like everiToken, it might divide the database into two parts,
Token DB, and another is
Block DB. Both
Token DB and
Block DB should be a versionized DB for fast rollback when a block
is reversed. For example, everiToken uses
Token DB is a indexed DB for quickly finding the newest status of the blockchain such as the ownership of tokens and the balance for fungible tokens of accounts on the chain. When executing a transaction, changes the owner in DB. Token DB is a append-only database so new data will be appended, the version of DB will be increased, and old value won’t be removed instantly. Old versions could be used to rollback the value if the block is reversed and will eventually be garbage collected.
Block DB is in charge of storing all the original irreversible blocks of the chain. Each Block stores all the detail information including the name and parameters of actions executed, the signatures that is on the block and some extra information.
The following graph shows how do two kinds of databases work together for NFT tokens:
Comparing to other transaction models
In the UTXO model, each token owner transfers a coin they own to another by digitally signing the hash of a previous transaction and the public key (address) of the next owner and adding these to the end of the coin. The mechanism is essentially a continual transgression of inputs and outputs where the owner of tokens actually does not directly own the tokens, but rather owns the output to a specific number of tokens that can then be signed over as an input to a new owner who then controls the new outputs.
As you can see, UTX is great for avoiding double-spending as it is obvious that any input could only be used once. But it also has some disadvantages:
- BTC is not a kind of NTF, it is a FT. It is useless to keep a unique id for every UTXO. (everiToken moves it to NFT use.)
- UTXOs are one-off. It's a waste of computing resources and disk volume to store that huge amount of UTXOs.
Balance-based transaction model is just like what does a bank do. You create a account in a bank and then save money into the account. The bank changes the balance of your account. There is no something like UTXO. It's more efficient than UTXO because it only changes a number in the database. But obviously it is not suitable for NFTs.
Continue Reading: Consensus Algorithm