当前位置:网站首页>2. Create your own NFT collections and publish a Web3 application to show them start and run your local environment
2. Create your own NFT collections and publish a Web3 application to show them start and run your local environment
2022-07-01 18:47:00 【Han Ru_】
A little introduction to blockchain
First , We need to make the local Ethereum network work properly . That is how we compile and test our smart contract code ! Do you know how you need to start a local environment to work ? Same thing here !
Now? , You just need to know , A smart contract is a piece of code that exists on the blockchain . Blockchain is a public place , Blockchain is a public place , Anyone can read and write data safely for free . Think about it a bit like AWS or Heroku, Except that no one really owns it ! It is called by thousands “ The miners ” Random person management .
The general idea here is :
1 – We need to write a smart contract . The contract includes us NFT All the logic of .
2 – Our smart contract should be deployed on the blockchain . such , Anyone in the world can view and call our smart contract , This contract is that we will allow them to cast NFT The contract of !
3 – We will set up a customer website , So that people can easily cast from our collection NFT.
I suggest you also read these file . in my opinion , These are the best guides on the Internet to understand how Ethereum works !
️ Set up local tools
We will use the name Hardhat Tools for , It enables us to quickly compile smart contracts , And test locally . First , You need to get node/npm. If you don't have it , succeed in inviting sb. here .
Be careful : I am here node 16 On . I know that some people encounter on the old version of the node “ Out of memory error ”, So if this happens , Please get node 16!
Next , Let's go terminal . Here, first create a folder locally :epic-nfts, Go ahead and cd Go to the working directory .

The terminal runs these commands :
mkdir epic-nfts
cd epic-nfts
npm init -y
npm install --save-dev hardhat
Run the last command and install Hardhat after , You may see messages about vulnerabilities . Each time from NPM When installing a software , Will carry out safety inspection , To see if there are any reported vulnerabilities in any software packages in the library you are installing . This is more like a warning to you ! If you want to learn more , Please be there. Google Search for these vulnerabilities on !
Then the local directory structure :

Run the sample project
cool , Now we have hardhat 了 . Let's start a sample project .
npx hardhat
Pictured :

Be careful : If you are in Windows Upper use Git Bash install hardhat, You may find yourself in this step (HH1) Encounters an error . If there is a problem , You can try Windows CMD perform HardHat install . Can be in here Find other information .
Choose the option to create a basic sample project . All choose yes , That is input y.

The sample project will require you to install hardhat-waffle and hardhat-ethers. These are what we will use later .
Continue installing additional dependencies , In case it doesn't install automatically .
npm install --save-dev @nomiclabs/hardhat-waffle ethereum-waffle chai @nomiclabs/hardhat-ethers ethers

You also need to install one called OpenZeppelin The library of , This is another library for developing secure smart contracts . Later we will learn more about it in detail . Now? , Just install it .
npm install @openzeppelin/contracts

And then run sample-script.js:

Execute at the terminal :
npx hardhat run scripts/sample-script.js
You should see the following :

If you also display this message , It means that your local environment has been set , And you also run on the local blockchain / Deployed smart contracts .
Next, let's discuss it in detail , What just happened step by step is :
- Hardhat Change your smart contract from solidity Compile as bytecode .
- Hardhat Will start on your computer “ Local blockchain ”. It's like a mini beta of Ethereum running on your computer , It can help you test things quickly !
- then ,Hardhat Will compile your contract “ Deploy ” To your local blockchain . That's the address you saw last . This is our contract deployed on the mini Ethereum .
If you are interested , You can check the code in the project at will , See how it works . say concretely , Check the smart contract file Greeter.sol And the actual contract documents sample-script.js.

After exploring , Let's move on to the next part and start our own NFT contract .
边栏推荐
- Solution: you can ping others, but others can't ping me
- 每周推荐短视频:警惕“现象”与“问题”相互混淆
- Lumiprobe non fluorescent alkyne EU (5-ethynyluridine)
- Lumiprobe Lumizol RNA 提取试剂解决方案
- Vidéos courtes recommandées chaque semaine: méfiez - vous de la confusion entre « phénomène » et « problème »
- 因子分析怎么计算权重?
- Regular expression
- R语言ggplot2可视化:可视化折线图、使用labs函数为折线图添加自定义的Y轴标签信息(customize y axis label)
- The R language uses the tablestack function of epidisplay package to make statistical summary tables (descriptive statistics based on the grouping of target variables, hypothesis testing, etc.). If th
- Navicat premium 15 permanent cracking and 2021 latest idea cracking (valid for personal testing)
猜你喜欢

What designs are needed in the architecture to build a general monitoring and alarm platform

宏观视角看抖音全生态

Leetcode-160相交链表

After studying 11 kinds of real-time chat software, I found that they all have these functions

MySQL connection tools

Principal component calculation weight

Three.js学习-相机Camera的基本操作(了解向)

Leetcode-128 最长连续序列

Why do independent website sellers start to do social media marketing? The original customer conversion rate can be improved so much!

12. Design of power divider for ads usage record
随机推荐
Write it down once Net travel management background CPU Explosion Analysis
The ultimate version of the 13th simulation of the single chip microcomputer provincial competition of the Blue Bridge Cup
1380. Lucky number in matrix / 1672 Total assets of the richest customers
Memo - about C # generating barcode for goods
How does factor analysis calculate weights?
Popular science: what does it mean to enter the kernel state?
主成分之综合竞争力案例分析
NSI packaging script add file details
Localization through custom services in the shuttle application
GameFramework食用指南
R language ggplot2 visualization: visualize the line graph and add customized Y-axis label information to the line graph using the labels function
Principal component calculation weight
《Go题库·16》读写锁底层是怎么实现的
Leetcode-141环形链表
Thread forced join, thread forced join application scenarios
信度系数低怎么办?信度系数具体怎么算?
R language uses the DOTPLOT function of epidisplay package to visualize the frequency of data points in different intervals in the form of point graph, and uses PCH parameters to customize the shape o
D. Yet Another Minimization Problem
Leetcode-83 删除排序链表中重复的元素
记一次 .NET 差旅管理后台 CPU 爆高分析