我正在创建一个ERC20令牌,我想为我的令牌指定一个最大的供给吗?
我想要制造2000枚代币。
我钱包里有1000个代币,剩下的1000个代币留在合同里。
这有可能吗?
发布于 2021-10-25 20:45:44
您可以使用以下代码使用OpenZeppelin实现这一目标:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract ERC20FixedSupply is ERC20 {
constructor() ERC20("Fixed", "FIX") {
_mint(msg.sender, 1000); // Mints 1000 tokens to your wallet
_mint(address(this), 1000); // Mints 1000 tokens to the contract
}
}在docs 这里中还有更多的信息!
https://ethereum.stackexchange.com/questions/112215
复制相似问题