麒麟QILIN只涨不跌智能合约系统开发方案详细/项目案例/需求功能/源码程序

简介: constructor() ERC721("the smart contract's name", "SYMBOL")

构造方法
constructor() ERC721("the smart contract's name", "SYMBOL") {
baseUri = "ipfs://xxxxxxxxxxxxxxxxx/";
whiteRootOG = xxxxxxxx;
whiteRootNormal = xxxxxxxxx;
// for(uint256 i = 1; i <= TOKENS_RESERVED; ++i) {
// _safeMint(msg.sender, i);
// }
// totalSupply = TOKENS_RESERVED;
}

构造方法第一个参数为合约名字,baseUri为ipfs的json地址,白名单稍后会讲解,构造方法这里有些合约会直接构造出来几个给团队自己使用,看自己需求。

ipfs
ipfs全名InterPlanetary File System, 是一个分布式的web,实现了点到点超媒体协议,可以让我们的互联网速度更快,更加安全, 并且更加开放。 理论上的话未来可以取代http。如果我们传上去一个相同的图片,得到的ipfs链接是一样的,所以ipfs比http更能确保文件的安全性,而且由于是p2p的形式去下载,所以下载速度相较http也会快速很多。
ok,简单介绍了下ipfs,那么我们该如何使用呢?
ipfs上传工具目前还是比较多的,我这里建议使用ipfs desktop,像pinata也很方便,但普通用户都有存储限制。
首先我们上传一个包含图片的文件夹以后获取到一个ipfs的cid地址,然后我们就得生成一个json去告诉用户,你的nft的图片,描述,名字等。
类似:

当然一般nft使用场景里会有很多很多nft,那么这里就需要把生成json文件脚本化比较方便了,其实就是一个string字符串写入生成文件,可以用java,python等,这里就不贴了。

然后刚才生成的json文件夹必须取名为metadata,然后这个metadata文件夹的ipfs cid即是我们合约里要用到的baseUri,当然这个baseUri也是可以动态替换的,这个后面会详解,主要用在一些一开始给到用户的nft是未揭秘,然后解密后的这种场景。
function mint(uint256 _numTokens, bytes32[] calldata whitelist_og_proof, bytes32[] calldata whitelist_normal_proof) external payable {
require(isSaleActive, "The sale is paused.");
require(_numTokens <= MAX_MINT_PER_TX, "You cannot mint that many in one transaction.");
require(mintedPerWallet[msg.sender] + _numTokens <= MAX_MINT_PER_TX, "You cannot mint that many total.");
uint256 curTotalSupply = totalSupply;
require(curTotalSupply + _numTokens <= MAX_TOKENS, "Exceeds total supply.");
require(_numTokens * price <= msg.value, "Insufficient funds.");

    for(uint256 i = 1; i <= _numTokens; ++i) {
        _safeMint(msg.sender, curTotalSupply + i);
    }
    mintedPerWallet[msg.sender] += _numTokens;
    totalSupply += _numTokens;
}
相关文章
|
7月前
|
安全 区块链 算法
dapp去中心化大小公排二二复制/三三复制系统开发指南功能丨需求方案丨案例设计丨成熟技术丨源码出售
区块链智能合约(Smart Contract)是一种在区块链技术中实现可编程逻辑的计算机代码。它们可以自动执行合约中包含的条件和操作,从而在区块链上创建一个不可篡改、安全和可靠的数字合约。
|
4月前
|
区块链
麒麟(QILIN)智能合约去中心化底池系统开发稳定版/案例项目/需求方案/源码详情
uint public constant MAX_TOKENS = 2000; uint private constant TOKENS_RESERVED = 4;
|
4月前
|
监控 供应链 安全
dapp智能合约只涨不跌系统开发步骤详细/开发案例/功能需求/方案项目/源码功能
需求分析:明确系统的功能需求和业务逻辑。确定系统需要支持的资产类型、交易规则和逻辑限制等。
|
7月前
|
安全
IPPswap交易所系统开发详细指南丨需求设计丨教程方案丨源码项目
Based on the development of the IPPSwap exchange exchange exchange bottom pool LP pledge mining system you mentioned, the following is an overview of its basic process and elements
|
7月前
|
供应链 算法 区块链
智能合约互助公排系统开发指南与方案
作为一种自动执行的协议,智能合约被嵌入在区块链计算机代码中
|
8月前
|
安全
dapp众筹矩阵公排互助系统开发指南详细丨功能需求丨案例项目丨方案项目丨源码程序
Requirement analysis and planning: Clarify the system's goals and functional requirements. Understand the characteristics and working methods of the DApp crowdfunding matrix mutual assistance system. Collect user requirements, define the crowdfunding mechanism, matrix common ranking algorithm, and m
|
8月前
|
安全
交易所开发正式版丨交易所系统开发详细指南/案例开发/功能需求/方案逻辑/项目设计/源码程序
Business requirement analysis: A detailed understanding of the business requirements of the exchange, including supported transaction types, transaction pair settings, fee mechanisms, user management, etc., to ensure that the development is in line with actual needs.
|
8月前
|
SQL 安全 区块链
交易所系统开发(案例项目)丨区块链交易所系统开发(稳定版)/成熟技术/步骤逻辑/源码教程
The development of a blockchain exchange system involves complex technologies and functions.
|
8月前
|
安全
交易所开发源码丨交易所系统开发成熟技术/案例开发/需求功能/项目方案/详细程序/多版本
The development of an exchange system involves multiple aspects and functions. The following are the main functions that may be included in general and some detailed guidelines:
|
8月前
|
存储 区块链 数据安全/隐私保护
秒合约跟单系统开发功能与细节|秒合约系统源码搭建(成熟案例)
区块链智能合约目前还在发展初期,存在诸多问题。