简体   繁体   English

在传递函数中使用自定义参数创建ERC20令牌

[英]create ERC20 token with custom parameters in transfer function

I have created the ERC20 token and its working fine, using the following code 我使用以下代码创建了ERC20令牌及其工作正常

https://ropsten.etherscan.io/address/0x299d8c3672b95f5a38af9a8d69590c4546219859#code https://ropsten.etherscan.io/address/0x299d8c3672b95f5a38af9a8d69590c4546219859#code

Problem i want to add one custom parameter while transfering erc20 token so i have added one parameter project Type in the transfer function as mentioned below 问题我要在传输erc20令牌时添加一个自定义参数,因此我在传输函数中添加了一个参数项目类型,如下所述

https://ropsten.etherscan.io/address/0x869Ac98EC03f220F6C49AaD2AabA4ad53924e74B#code https://ropsten.etherscan.io/address/0x869Ac98EC03f220F6C49AaD2AabA4ad53924e74B#code

whenever i tried to transfer some token from metamask or from the application using web3. 每当我尝试从metamask或使用web3的应用程序转移一些令牌时。 transaction is getting failed. 交易失败。 Is anybody faced the same issue? 有人面临同样的问题吗?

Regards Manikandan C 关于Manikandan C

The ERC20 interface is not a piece of code. ERC20接口不是一段代码。 It is an agreement amongst programmers on what the contract should look like. 程序员应就合同的外观达成协议。

Agreement between groups of programmers is usually called a "standard". 程序员组之间的协议通常称为“标准”。 That's why ERC20 is often called a token standard. 这就是为什么ERC20通常被称为令牌标准的原因。

In code, the standard is implemented as an interface so the compiler can check weather you have complied to the standard. 在代码中,该标准实现为接口,因此编译器可以检查您遵守该标准的天气。

If you change the interface, you change the standard. 如果更改接口,则更改标准。 Therefore what you have programmed is no longer an ERC20 token. 因此,您编程的内容不再是ERC20令牌。 It is therefore not surprising that other software refuse to accept the smart contract as an ERC20 token because it is not an ERC20 token. 因此,其他软件拒绝接受智能合约作为ERC20令牌也就不足为奇了,因为它不是ERC20令牌。

If you want to make modifications 如果要进行修改

It should be noted that interfaces only enforce what MUST be implemented. 应该注意的是,接口仅强制执行必须实现的内容。 There is no restriction on any functions you want to add. 您要添加的任何功能都没有限制。 So you are free to add a specialTransfer() function if you want. 因此,您可以根据需要随意添加specialTransfer()函数。

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

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