Skip to main content

Custom Tokens

Introduction

The token economy is the most impacting transformation blockchain and distributed ledger technologies have brought us so far. A token can serve multiple purposes: financial participation in a company ("stock"), mileage or loyalty points of a specific store or network, votes, ownership of digital goods such as website domains, etc. On top of decentralized networks, these can be exchanged freely, without a central authority or intermediary.

On Hathor Network, any user has the power to create new tokens. They behave exactly under the same technical assumptions as the Hathor's native tokens (HTR). In other words, they are highly scalable; ownership is secured by digital signatures; and there's no fee for exchanging tokens among users.

After token has been created, it may be freely exchanged exactly like Hathor's native tokens (HTR). It is possible to create transactions with more than one token, including HTR and custom tokens. Transactions with multiple tokens are useful to allow users to exchange their custom tokens with HTR with no intermediary exchange (and no fees).

Basic operations

There are be several administrative tasks for a custom token. The most basic administrative tasks are: (i) token mint operation, and (ii) token melt operation. The token mint operation is used to issue new tokens, while the token melt operation is used to destroy tokens.

Token Creation

Token creation happens in a special transaction output, called initial authority UTXO, giving an address the authority over this token. This authority gives its holder the ability to mint or melt new tokens and may also be transferred to other addresses. Initially, this new token has zero issued tokens.

As token authority is represented by an UTXO, it can only be used once. This means that using this UTXO as an input to mint tokens, for example, prevents this same output from being used again. If one wishes to keep his authority when minting tokens, one should also create another authority UTXO alongside the new tokens. Minting a token and removing all authority over it is useful to create tokens with a provable supply limit, as no new tokens can be minted.

Token Issuance

Token issuance happens in a special transaction and requires a mint authority UTXO. The maximum number of units that may be issued in a single transaction is 9,223 trillions.

In order to issue new tokens, one must only create a new transaction and propagate it to the Hathor's network. The transaction will be confirmed exactly as any other transaction by the network.

Token Destruction

Token destruction happens in a special transaction and requires a melt authority UTXO. The transaction must include all outputs to be destroy, and can generate new inputs to partially destroy an output.

In order to melt tokens, one must only create a new transaction and propagate it to the Hathor's network. The transaction will be confirmed exactly as any other transaction by the network.

Technical details

A token exchange is very similar to any regular hathor transaction. In fact, different tokens and hathors can be combined in the same transaction, as long as the sum of inputs and outputs is the same for each token (including hathors).

Each different token has a 32-byte hash as unique identifier (token uid), similar to a transaction hash. HTR tokens are the only special case and don't have a token uid (we consider it 0).

The following image shows a transaction B (txB) which spends all outputs of txA. There are 2 tokens present: HTR and my token. For simplicity, we represent mytoken's uid as <mytoken>, which in reality is a 32-byte hash. In this example, txB only spends outputs from txA, but it could spend outputs from different transactions.

tokens

When verifying txB inputs, there's no special operation to perform for the tokens. We just need to validate script_data of each input with the matching output's script. We then need to check if the sum of inputs and outputs match for each token. In this case, we have:

inputs:                 outputs:  
- hathors: 50           - hathors: 50  
- mytoken: 30           - mytoken: 30  

Token creation

Comparison with ERC-20 tokens

Use cases

Milleage program

Stablecoin

Company stock

The future

Other ERCs compatible

KYC/AML regulations