Uncover the mystery token

A, token concept

1.token English version

Speaking EOSIO the token, we have to say the next token of the word.
First, we look at the English dictionary to say:

token
- n.
  代币; 象征; 记号;
- adj.
  作为对某事的保证的; 象征性的; 作为标志的;
- vt.
  预兆:预示或象征,预兆;
# 变形
复数: tokens

Token can be seen not only "tokens" means, but also includes integration, property certificates. If further expansion, it can also represent honor identity, identity-cum indeed the right tools, system assets quantitative indicators, the system passes and systems protection, which means you can become anything of interest or value represented.

2.token block chain awareness

So, the concept of the block chain, token of recognition should be? From the application point of view, Token actually an application, its purpose is to serve as tokens. The most typical example is the bit coins, coins ether, the EOS and the like.

Currently, Token divided into two categories:

The first class, the Token will be appreciated that the internal, i.e., to maintain the block chain operations token issued to encourage the creation and validation block miners, miners need to be performed by the block exchange work. In fact, this type can be understood as the encrypted digital currency can circulate.

The second category can be divided into equity and bond tokens tokens, similar to investment and debt, not money, is the reality of its representatives in stocks and bonds, buy can get some dividend and interest income in return.

In the block chain platform, token represents the value owned by the user. Users do all operations on the EOS platform will eventually fall based on circulation token, are of value as the core, this is entirely consistent with the way the flow and value of social currency that we are currently using.

There is a saying in currency circles that Token is a card through to freedom . The preacher said: Token essence, the technology is penetrating the financial rights, natural rights brought about by technological progress, each carbon biology and robotics are all equal , and every human can use their own credit to do endorsement issued Token to raise production (coins, count or equivalent force) to realize their ideas. Need not be of any use legal tender, human social structure of exploitation and coercion of all value , are based should be formed between man and man, man and machine, machine and machine consensus, to be confirmed by the algorithm .

对于数字货币信仰者来说,Token是通往自由的通证。
首先,第一次摆脱了『债』的体系,以『Token』来计量生产。
其次,Token是加密的,政府无法监管、无法剥夺、无法控制,100%避税,穿透了所有金融监管和法律体系,让金融牌照废纸化,是首个超越暴力控制的产权模式。
最后,Token天然是去中心化的、动态的,是认同的一种标志。随着核心生产资料从土地、矿产和能源,变成算力、智力和数据,劳动者、企业主的话语权越来越强,人才和智力是无法接受法币剥削的,只能撮合,交换,达成共识。

Two, token is how to create and issue, circulation

token concept we have clear, since it is a technique to achieve financial rights, then it must also itself with the financial characteristics of , how it is used in the block chain platform it? As a digital currency, and we use the real social characteristics of the legal tender remained the same, so there is also a need to create, issue and circulation process, but the system interface functions or processes required to provide these intelligent contract by the block chain platform to achieve . On the EOS platform, is achieved through the intelligent eosio.token contract . EOSIO in all contracts must be derived from the base class contract, contract defines the base class as follows:
Uncover the mystery token

Let's preliminary look eosio.token contract source structure, as shown below:
Uncover the mystery token

From the above code, we can clearly see the contract provides for a method of external token:

​ 三个代币的操作方法 create:创建代币issue:发行代币transfer:代币转账

​ 两个代币的查询方法 get_supply: 获取代币的供应量信息、get_balance:获取指定账号代币信息

​ 以上的方法中,使用到了一个定义为asset的类,这个类就是用来记录代币信息的对象类,其定义如下:
Uncover the mystery token

​ 我们可以看到,EOSIO中的asset资产类有两个私有成员变量,amount代表的是资产的数量,是个无符号64位整数;而sym则代表了当前资产的代币类型对象

三、token是如何在EOSIO中进行精度化存储和使用的

​ 我们在平时使用EOS时,有时会发现代币有带小数点后几位的情况,但是之前介绍的token合约中,我们看到的asset资产类中的数量类型却是无符号64位整数,这是怎么回事呢?下面我们来具体的看下EOS中是如何来对资产信息进行精度化存储和使用的。

​ 重点看下symbol的定义,如下:
Uncover the mystery token

还有需要我们关注的实现代码相关的内容:string_to_symbol_c方法,实现了给出代币小数点精度和名称后生成相应代币对象唯一uint64_t ID 的过程。
Uncover the mystery token

symbol的方法实现:
Uncover the mystery token

asset的to_real方法:
Uncover the mystery token

从上面的这段代码再结合之前的asset的方法,我们可以认识到如下几点:

a.代币的小数点后精度和代币的名称字串能够生成一个唯一的uint64_t类型的代币ID值

B. token uint64_t object stored in a type of space, the lowest eight bits of precision value, the other seven bytes in the reverse endian byte names stored tokens . Example: token (18, "GALAXY") in the storage space is such that, as shown below:
Uncover the mystery token

c. The final asset storage is uint64_t type number stored value, the token type corresponding decided when the value stored in the taken out use, it is necessary according to the calculated conversion rate, to numeric conversion , which is Why do we see there is a method called to_real in the asset class, it is the direct conversion in addition to the number of the number of values. When the stored number is an integer value, multiplied by the number of terms, during removal, is divided by an integer value in terms of numbers, as shown, is external asset A floating point representation, but the storage time is stored integer values, conversion process is as follows:
Uncover the mystery token

link

Galaxia public chain

Guess you like

Origin blog.51cto.com/14267585/2403335