Hedera Token Service

 

The Hedera Token Service

I continue this series with a brief examination of the Hedera Token Service (HTS).

As I noted in my documentation overview, my base source of truth on HTS is the Hedera Tokenization Whitepaper. The whitepaper lays out the objectives and strategy for token management in the Hedera ecosystem. It establishes a few definitions, and discusses how tokens are deployed on Hedera. It then describes the Hedera Consensus Service's role in token management. The benefits of both the HTS and HCS are touched upon, and examples are provided. Let’s look into it it more detail.

Four Key Concepts

The whitepaper reviews four key concepts: tokens, token contracts, token state, and token accounts. Let's look at all four of these briefly.

Tokens

I couldn't be brief about tokens, since everything revolves around tokens and token management. So I went into tokens in depth in my previous posting. That surely won't be the end of the story on tokens; when I start going through the samples and tutorials, I'll likely discover much more.

Token Contracts

This is the code you use to create a token. The contract is public, which makes third-party audits possible. The whitepaper mentions that the implementation of a token contract differs if the token is created using the HTS or using the Hedera Consensus Service (HCS). I’ll explore this when I look at the HCS in my next post.

Token State

Who owns the token? What is its balance? What is its transaction history? Questions like these refer to the state of the token, and can be answered by querying. As with token contracts, the whitepaper asserts that implementation differences exist between State on the HTS and HCS. This may mean that querying techniques are significantly different in both. Another thing for me to discover.

Token Accounts

Account hold balances of tokens, and are the springboards for token movement. You need an account to do anything with a token. Predictably, the types of accounts differ between tokens created on the HTS and HCS.

On to the HTS

Okay, I’m finally ready to look at bit more at the HTS. After all this buildup with token info this’ll seem pretty brief.

Once you define a token, the whitepaper suggests two elemental ways you can use it: in transactions or in queries. This is regardless if your token is fungible or non-fungible.  

For transactions, the HTS provides an initial set of nine API methods which enable you to create and manage tokens (21 methods as of this writing). You can create, mint, burn, and do more with tokens, all using the HTS API. Hedera’s getting started tutorials have you delve into this, something I’ll be doing soon enough. 

Finally, the whitepaper suggests you can execute queries against a token's state (its identity, properties, or transactions). This is mentioned almost in passing, but it is an important use case for the HTS. Every time you execute a token transaction, a record of that transaction is created on the ledger immediately and cannot be changed. The querying aspect of the HTS is what enables audits and reporting of state. NFT explorers are examples of apps that can issue queries against Hedera tokens and ledger history. Another thing that I’ll be looking into before long.  

Since the whitepaper was released, more facility supporting querying is available with token metadata. The NFT Token Metadata JSON Schema V2 provides extended support. Michiel Mulders describes this very well. 

The key thing about invoking these transactions and queries via the HTS, is that with the HTS you don’t need to make use of any smart contract service to do them. So you not only take advantage of Hedera’s speed and trust in managing your tokens, but your transaction costs are much, much lower than if you had to use a smart contract.  

Stopping Point 

Okay, that enough of an initial overview of the Hedera Token Service. I'd like to start poking around with it, but I do need to put the other services in context beforehand. Patience, grasshopper.

My next post will be on the Hedera Consensus Service. As I research it, I’ll keep my mind open for these new items on my technical watchlist. 

  1. Dig into the Hedera Getting Started documentation.

  2. How are token contracts, state, and accounts different in the context of the HTS and HCS?

  3. Is the technique I use to query token metadata significantly different between the HTS and HCS? If so, why?

  4. Investigate token explorers. How can they help me as a developer?
Thanks for reading, and stay tuned.

Comments

Popular posts from this blog

The Hedera Consensus Service (HCS)

Hedera Tokens

Welcome to the I'm Learning Hedera blog.