坚固文档薄荷并发送功能
在文档固体中有这个硬币示例,我阅读了文档,但我不明白两者的区别和目的是什么?什么薄荷和发送功能在做什么? 发送功能是有道理的,但薄荷功能令人困惑。 “将新创建的硬币发送到地址,只能由合同创建者调用”的含义是什么”
In the documentation solidity has this coin example, I read the documentation but I couldn't understand what is the difference and purpose of both? What mint and send functions are doing?
The send function makes sense but mint function is confusing.
What is the meaning of "Sends an amount of newly created coins to an address, can only be called by the contract creator"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当部署硬币合同时,只要您创建某些东西,就没有什么可使用的。创建硬币的过程称为铸造。
如果您想要定期转移:地址(Alice)发送到地址(BOB)
如果您有一种方法:地址(无)可以地址(合同创建者),那么您可以创建硬币。
这是有道理的,因为铸造从稀薄的空气中创造了价值,而且该合同希望只允许创造者。
When the coin contract is deployed, there is nothing to use as long as you create something. The process of creating coins is referred to as minting.
If you want a regular transfer: address(Alice) sends to address(Bob)
If you have a method to do: address(Nothing) to address(Contract Creator), now you can create coins.
This makes sense since minting creates value out of thin air, and this contract wants to allow no one but the creator.
如果您查看
mint
函数,它具有此requief
语句:因此,只有“ minter”才能调用。 “ Minter帐户”将创建新的代币,刻录令牌并将令牌分发到其他帐户或出售令牌。因此合同所有者创建者和财务管理员分开。您设置
Minter
时部署合同时:在面向对象的编程中,
构造函数
在创建类的实例时,请调用。以坚固性,我们在部署合同时创建合同实例。当我们部署合同时,我们必须通过此参数。如果您以混音部署部署,则将拥有以下操作:您必须在框中输入Minter地址。
发送
函数定义为公共,因此任何人都可以调用它。在上面的示例中,它只是用于将一些硬币发送到接收器帐户。If you look at the
mint
function, it has thisrequire
statement:so only "minter" can call this. "Minter account" will be creating new tokens, burn tokens and distributing the token to other accounts or selling tokens. So contract owner creator and financial admin are separated. You set the
minter
when you deploy the contract:In object-oriented programming,
constructor
is called when you create an instance of the class. In solidity we create an instance of contract when we deploy the contract. When we deploy the contract we have to pass this parameter. If you deploy on remix, you would have this:you have to enter the minter address into the box.
send
function is defined as public, so anyone can call it. In above example, it is just used to send some coin to receiver account.