当前位置:网站首页>How to release NFT in batches in opensea (rinkeby test network)
How to release NFT in batches in opensea (rinkeby test network)
2022-07-07 15:15:00 【Meta wuyanzu】
One 、 Generate NFT image
HashLips Art Engine It is a tool for creating multiple instances of different works of art based on the provided layers .
1. install
npm install
or
yarn install
2. Use
stay “layers” Create different layers in the directory as folders , And add all layer resources in these directories . Once you have all the layers , Get into src/config.js And update the layerConfigurations Object's layersOrder Array , according to The order from low level to top level , Make it your layer folder name .
Of each layer object name Represents the name of the folder where the image is located ( stay /layers/ in ).
growEditionSizeTo: Number of generated images .
to update format Size , That is, the size of the output image .
shuffleLayerConfigurations The default is false, All images will be saved in numerical order . If set to true, The order in which images are saved will be confused .
You can also send a message to config.js In the document extraMetadata Add extra items to object variables (key: value) To add additional metadata for each metadata file .
const extraMetadata = {
creator: "Tiger",
};
Debug script package.json
"scripts": {
"build": "node index.js",
"generate": "node index.js",
"rarity": "node utils/rarity.js",
"preview": "node utils/preview.js",
"pixelate": "node utils/pixelate.js",
"update_info": "node utils/update_info.js",
"preview_gif": "node utils/preview_gif.js",
"generate_metadata": "node utils/generate_metadata.js"
}
2.1 Run the command node index.js(or npm run build) The output artwork will be in build/images Directory , and json stay build/json Directory .
2.2 to update IPFS Of baseUri And description
src/config.js Medium baseUri = “ipfs://NewUriToReplace”
// General metadata for Ethereum
const namePrefix = "My Collection";
const description = "Remember to replace this description";
const baseUri = "ipfs://QmZwo1rMdDMErLx6csTjLEzhm6WpYDjJwciNq3KUVdc4GX";
QmZwo1rMdDMErLx6csTjLEzhm6WpYDjJwciNq3KUVdc4GX yes ipfs in images The folder CID.
Carry out orders :node utils/update_info.js or npm run update_info
2.3 Generate preview image
npm run preview
2.4 Generate a pixelated image from a set
npm run pixelate
All images will be output to /build/pixel_images Directory . If you want to change the ratio of pixelation , You can update the file pixelFormat The ratio attribute of the object src/config.js. The lower the number on the left , The higher the degree of pixelation of the image .
const pixelFormat = {
ratio: 5 / 128,
};
2.5 Print rare data
npm run rarity
Trait type: Bottom lid
{
trait: 'High',
weight: '20',
occurrence: '26 in 100 editions (26.00 %)'
}
{
trait: 'Low',
weight: '40',
occurrence: '33 in 100 editions (33.00 %)'
}
{
trait: 'Middle',
weight: '40',
occurrence: '41 in 100 editions (41.00 %)'
}
Two 、 Upload the image to IPFS
1. install IPFS after , Select import , Click on folder , Choose images Folder and upload .
2. to update json Information
- Copy images The folder CID, Paste to src/config.js Medium baseUri in .
3. Carry out orders :node utils/update_info.js or npm run update_info
3. Select import , Click on folder , Choose json Folder and upload .
3、 ... and 、NFT Intelligent contract
// SPDX-License-Identifier: MIT
// Amended by HashLips
/** !Disclaimer! These contracts have been used to create tutorials, and was created for the purpose to teach people how to create smart contracts on the blockchain. please review this code on your own before using any of the following code for production. HashLips will not be liable in any way if for the use of the code. That being said, the code has been tested to the best of the developers' knowledge to work as intended. */
pragma solidity >=0.7.0 <0.9.0;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract NFT is ERC721Enumerable, Ownable {
using Strings for uint256;
string baseURI;
string public baseExtension = ".json";
uint256 public cost = 0.00001 ether;
uint256 public maxSupply = 10000;
uint256 public maxMintAmount = 20;
bool public paused = false;
bool public revealed = false;
string public notRevealedUri;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI,
string memory _initNotRevealedUri
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
setNotRevealedURI(_initNotRevealedUri);
}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
// public
function mint(uint256 _mintAmount) public payable {
uint256 supply = totalSupply();
require(!paused);
require(_mintAmount > 0);
require(_mintAmount <= maxMintAmount);
require(supply + _mintAmount <= maxSupply);
if (msg.sender != owner()) {
require(msg.value >= cost * _mintAmount);
}
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(msg.sender, supply + i);
}
}
function walletOfOwner(address _owner)
public
view
returns (uint256[] memory)
{
uint256 ownerTokenCount = balanceOf(_owner);
uint256[] memory tokenIds = new uint256[](ownerTokenCount);
for (uint256 i; i < ownerTokenCount; i++) {
tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokenIds;
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if (revealed == false) {
return notRevealedUri;
}
string memory currentBaseURI = _baseURI();
return
bytes(currentBaseURI).length > 0
? string(
abi.encodePacked(
currentBaseURI,
tokenId.toString(),
baseExtension
)
)
: "";
}
//only owner
function reveal() public onlyOwner {
revealed = true;
}
function setCost(uint256 _newCost) public onlyOwner {
cost = _newCost;
}
function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner {
maxMintAmount = _newmaxMintAmount;
}
function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner {
notRevealedUri = _notRevealedURI;
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function setBaseExtension(string memory _newBaseExtension)
public
onlyOwner
{
baseExtension = _newBaseExtension;
}
function pause(bool _state) public onlyOwner {
paused = _state;
}
function withdraw() public payable onlyOwner {
// This will pay HashLips 5% of the initial sale.
// You can remove this if you want, or keep it in to support HashLips and his channel.
// =============================================================================
(bool hs, ) = payable(0x943590A42C27D08e3744202c4Ae5eD55c2dE240D).call{
value: (address(this).balance * 5) / 100
}("");
require(hs);
// =============================================================================
// This will payout the owner 95% of the contract balance.
// Do not remove this otherwise you will not be able to withdraw the funds.
// =============================================================================
(bool os, ) = payable(owner()).call{
value: address(this).balance}("");
require(os);
// =============================================================================
}
}
Constructors
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI,
string memory _initNotRevealedUri
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
setNotRevealedURI(_initNotRevealedUri);
}
_name:NFT name
_symbol:NFT Symbol
_initBaseURI: Set up BaseURI
_initNotRevealedUri: Set not to expose URI Display field of
stay Remix Last contract deployment
1. open Metamask
Switch Rinkeby The Internet
2. remix Choose the execution environment
3. Deploy contract transfer parameters
_initBaseURI:“ipfs://QmVAQetWCZcX187qGu7heW3uEmdgPeGQhbdsv3YQc6PTTW/”
QmVAQetWCZcX187qGu7heW3uEmdgPeGQhbdsv3YQc6PTTW by json The folder CID.
Successfully deployed :https://rinkeby.etherscan.io/address/0x42fE9E6345B26FDbeC7130823d48142B6dC1407f
3. Casting nft
perform mint function
obtain tokenURI
1. perform tokenURI() function .
because revealed The default is false, No display tokenURI.
2. perform reveal() function ,revealed more true.
3. Re execution tokenURI() function .
here tokenURI To expose the state .
Four 、 stay opensea Import smart contracts on the website
1. Import contracts from the main network
2. Import contracts from the test network
3. design sketch
边栏推荐
- Ctfshow, information collection: web2
- 2.Golang基础知识
- 有一头母牛,它每年年初生一头小母牛。每头小母牛从第四个年头开始,每年年初也生一头小母牛。请编程实现在第n年的时候,共有多少头母牛?
- Niuke real problem programming - day16
- PG basics -- Logical Structure Management (locking mechanism -- table lock)
- Novel Slot Detection: A Benchmark for Discovering Unknown Slot Types in the Dialogue System
- Briefly describe the working principle of kept
- buffer overflow protection
- Stm32f103c8t6 PWM drive steering gear (sg90)
- Ctfshow, information collection: web1
猜你喜欢
CTFshow,信息搜集:web4
【OBS】RTMPSockBuf_ Fill, remote host closed connection.
Stm32cubemx, 68 sets of components, following 10 open source protocols
CTFshow,信息搜集:web14
Ctfshow, information collection: web12
简述keepalived工作原理
[deep learning] semantic segmentation experiment: UNET network /msrc2 dataset
Niuke real problem programming - day13
Cocoscreator operates spine for animation fusion
Notes HCIA
随机推荐
避坑:Sql中 in 和not in中有null值的情况说明
“百度杯”CTF比赛 2017 二月场,Web:include
2022年5月互联网医疗领域月度观察
Niuke real problem programming - day13
拜拜了,大厂!今天我就要去厂里
Cocoscreator operates spine for animation fusion
Niuke real problem programming - day20
Do you know the relationship between the most important indicators of two strong wind control and the quality of the customer base
MySQL installation configuration 2021 in Windows Environment
How does the database perform dynamic custom sorting?
FFmpeg----图片处理
Ffmpeg --- image processing
MySQL bit类型解析
Ctfshow, information collection: Web3
【搞船日记】【Shapr3D的STL格式转Gcode】
Mathematical modeling -- what is mathematical modeling
Promoted to P8 successfully in the first half of the year, and bought a villa!
#HPDC智能基座人才发展峰会随笔
Today's sleep quality record 78 points
Xiaomi's path of chip self-development