Skip to content

Multi Native Token in QuarkChain

qcdll edited this page Jan 22, 2019 · 3 revisions

Background

https://medium.com/quarkchain-official/supporting-multi-native-tokens-in-a-single-blockchain-686fc65f5931

Design Rationale

  • Treat all tokens equally, there is no cost difference to process transactions setting different gas_token_id and transfer_token_id
  • Compatibility with EVM, keep original EVM opcode and add new ones to support querying token balances

Design

  1. Token Balance Storage: to store a balance mapping, we can use either a list of token:balance pair, or use a trie structure and store in DB. Accounts with just a handful of token balances can benefit from using the balance pair list by avoiding to touch storage when reading/writing
  2. DEFAULT_TOKEN: each chain ID should pose a genesis native token as: (1) block reward (2) default token to use when EVM performs CALL or BALANCE without supplying token_id

Terms Explanation

  • Genesis Token: default token for all the network, block coinbase reward will be paid in genesis token
  • Default Chain Token: default token for EVM, this can be different than Genesis Token, allowing chains to use different tokens for EVM

All tokens are stored in the same way, and there is no performance advantage to use one token over another.