V2EX 10月28日 10:11
WUZHU_V1:首款UUPS模式ERC20代币合约
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文介绍了一个名为WUZHU_V1的ERC20代币合约,采用UUPS升级模式,符合特定项目规格,包括代币名称、符号、总供应量以及初始分配等。
// SPDX-License-Identifier: MITpragma solidity ^0.8.20;import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";/** * @title WUZHU_V1 * @dev This is the first version of the Wuzhu (VZU) token contract. * It is an upgradeable ERC20 token following the UUPS pattern. * * Conforms to the specifications in "PROJECT_GENESIS_PLAN.MD": * - Name: Wuzhu * - Symbol: VZU * - Decimals: 18 * - Total Supply: 21,000,000 * - Initial Allocation: 100% minted to the deployer. * - Upgradeability: UUPS proxy pattern. * - Ownership: Initially owned by the deployer (Captain's address). */contract WUZHU_V1 is Initializable, ERC20Upgradeable, OwnableUpgradeable, UUPSUpgradeable {    /// @custom:oz-upgrades-unsafe-allow constructor    constructor() {        _disableInitializers();    }    /**     * @notice Initializes the contract after deployment.     * @dev This function can only be called once. It sets the token's name, symbol,     * and mints the total supply to the contract deployer, who also becomes the owner.     */    function initialize() initializer public {        __ERC20_init("Wuzhu", "VZU");        __Ownable_init(msg.sender);        __UUPSUpgradeable_init();        // Mint the total supply of 21,000,000 tokens to the deployer.        // The number is multiplied by 10**18 to account for the decimal places.        _mint(msg.sender, 21000000 * 10**decimals());    }    /**     * @dev Authorizes an upgrade to a new implementation contract.     * This function is required by the UUPS pattern and restricts upgrade     * authority to the current owner.     */    function _authorizeUpgrade(address newImplementation)        internal        onlyOwner        override    {}}

就这么点代码,就是一个币。发币也框框调库。

真是不发不知道,一发吓一跳。

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

ERC20代币 UUPS升级模式 代币合约
相关文章