坚固文档薄荷并发送功能

发布于 2025-01-23 02:45:24 字数 275 浏览 0 评论 0原文

在文档固体中有这个硬币示例,我阅读了文档,但我不明白两者的区别和目的是什么?什么薄荷和发送功能在做什么? 发送功能是有道理的,但薄荷功能令人困惑。 “将新创建的硬币发送到地址,只能由合同创建者调用”的含义是什么”

Solidity Documentation

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我一向站在原地 2025-01-30 02:45:24

当部署硬币合同时,只要您创建某些东西,就没有什么可使用的。创建硬币的过程称为铸造。

将新创建的硬币发送到地址
通常认为铸造会从无处可将硬币发送到某个地方。这听起来可能令人困惑,但以这种方式考虑:

如果您想要定期转移:地址(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.

Sends an amount of newly created coins to an address
Minting is usually perceived to be sending coins somewhere from nowhere. This may sound confusing but think of it this way:

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.

can only be called by the contract creator

This makes sense since minting creates value out of thin air, and this contract wants to allow no one but the creator.

泅渡 2025-01-30 02:45:24

如果您查看mint函数,它具有此requief语句:

 // msg.sender is the account that calls the function
 require(msg.sender==minter)

因此,只有“ minter”才能调用。 “ Minter帐户”将创建新的代币,刻录令牌并将令牌分发到其他帐户或出售令牌。因此合同所有者创建者和财务管理员分开。您设置Minter时部署合同时:

    // you declare the state variable first
    address public _minter;

    // you assign a value during the construction of the contract

    constructor(address minter_){
        _minter=minter_;        
     }

在面向对象的编程中,构造函数在创建类的实例时,请调用。以坚固性,我们在部署合同时创建合同实例。当我们部署合同时,我们必须通过此参数。如果您以混音部署部署,则将拥有以下操作:

”在此处输入图像描述

您必须在框中输入Minter地址。

  • 发送函数定义为公共,因此任何人都可以调用它。在上面的示例中,它只是用于将一些硬币发送到接收器帐户。

If you look at the mint function, it has this require statement:

 // msg.sender is the account that calls the function
 require(msg.sender==minter)

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:

    // you declare the state variable first
    address public _minter;

    // you assign a value during the construction of the contract

    constructor(address minter_){
        _minter=minter_;        
     }

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:

enter image description here

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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文