简体   繁体   English

什么是ERC20标准

[英]What is ERC20 standard

this https://theethereum.wiki/w/index.php/ERC20_Token_Standard eth wiki describes erc20 standard as a set of functions and attributes a token needs to have implemented.这个https://theethereum.wiki/w/index.php/ERC20_Token_Standard eth wiki 将 erc20 标准描述为令牌需要实现的一组功能和属性。 some of them are pretty self explanatory like其中一些是不言自明的,比如

function transfer(address to, uint tokens) public returns (bool success);

which takes coins from your wallet and transfers it to somebody elses.它从您的钱包中取出硬币并将其转移给其他人。 But on the other hand但另一方面

function approve(address spender, uint tokens) public returns (bool success);

or或者

function allowance(address tokenOwner, address spender) public constant returns (uint remaining);

How am I supposed to know what is the logic behind these methods?我怎么知道这些方法背后的逻辑是什么? are there any extra docs describing it?是否有任何额外的文档描述它? and last but not least: what are upsides of tokens being ERC20 compliant?最后但同样重要的是:符合 ERC20 标准的代币有哪些优势?

ERC20 standard contains a set of functions that were proposed EIP-20 which were reviewed and voted on by community. ERC20 标准包含一组在EIP-20中提出的功能,这些功能由社区审查和投票。 As per abstract states the following:根据摘要陈述如下:

This standard provides basic functionality to transfer tokens, as well as allow tokens to be approved so they can be spent by another on-chain third party.该标准提供了转移代币的基本功能,并允许代币获得批准,以便另一个链上第三方可以使用它们。

See here for more some analogous examples on what approve and allowance do, but basically these are functions that allow an account owner to approve moving a fixed amount of tokens from their account to another account.有关approveallowance的更多类似示例,请参见此处,但基本上这些功能允许账户所有者批准将固定数量的代币从他们的账户转移到另一个账户。 approve allows you to authorize an address to move a fixed amount, while allowance simply returns this amount. approve允许您授权地址移动固定金额,而allowance只是返回此金额。

Looking at the EIP and ERC20 documentation can be a bit daunting at once, but one you start playing with the functions it makes a lot more sense.查看 EIP 和 ERC20 文档可能会让人有点望而生畏,但是当你开始使用这些函数时,它会变得更有意义。 For quickest way to start testing I'd suggest using Ethereum's remix.为了以最快的方式开始测试,我建议使用 Ethereum 的 remix。

If you think the documentation on that wiki is not enough, you can look at the original EIP and look at all of the discussions involved that led to the final version, along with links to additional documentation and code examples to further explain the intention of each function. 如果您认为该Wiki上的文档还不够,可以查看原始的EIP并查看导致最终版本的所有相关讨论,以及指向其他文档和代码示例的链接,以进一步说明每个文档的意图。功能。 Note that all of the ERCs have a corresponding EIP, so you can refer to those for all of the other token standards. 请注意,所有ERC都有相应的EIP,因此您可以参考所有其他令牌标准的EIP。

what are upsides of tokens being ERC20 compliant? 令牌符合ERC20的优点是什么?

The upside is that others will know how to work with your token. 好处是其他人会知道如何使用您的令牌。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM