JT1769119的个人空间 https://www.eechina.com/space-uid-172084.html [收藏] [复制] [RSS]

博客

红酒链游元宇宙DAPP系统制度开发项目详情

已有 346 次阅读2023-3-17 14:29

在两个或多个参与方之间执行特定的任务开发项目I76案例好的2o72演示9II9智能合约是区块技术世界不可或缺的一局部这些合约是软件程序,当满足了规则的条件时。从实质上说,它就像一个自执行的常规合约,不需求中介,由于它依赖于它的编程值。

红酒链游NFT智能合约的编程示例:

typescript
Copy code
pragma solidity ^0.8.0;

    function setBaseURI(string memory baseURI_) public onlyOwner {
        _baseURIExtended = baseURI_;
    }

    function _baseURI() internal view virtual override returns (string memory) {
        return _baseURIExtended;
    }
}

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract WineGometaNFT is ERC721, Ownable {
    uint256 public constant MAX_TOKENS = 10000;
    uint256 public constant PRICE = 0.1 ether;
    uint256 public constant MAX_PER_MINT = 10;

    string private _baseURIExtended;

    constructor(string memory _name, string memory _symbol, string memory baseURI) ERC721(_name, _symbol) {
        setBaseURI(baseURI);
    }

    function mint(uint256 _count) public payable {
        require(_count > 0 && _count <= MAX_PER_MINT, "Invalid number of tokens requested");
        require(totalSupply() + _count <= MAX_TOKENS, "Purchase would exceed max supply");
        require(msg.value == PRICE * _count, "Ether value sent is not correct");

        for (uint256 i = 0; i < _count; i++) {
            _safeMint(msg.sender, totalSupply() + 1);
        }
    }

评论 (0 个评论)

关于我们  -  服务条款  -  使用指南  -  站点地图  -  友情链接  -  联系我们
电子工程网 © 版权所有   京ICP备16069177号 | 京公网安备11010502021702
返回顶部