当前位置:网站首页>NFT transaction principle analysis (1)

NFT transaction principle analysis (1)

2022-06-26 15:44:00 NFT practitioner

NFT Transaction process analysis

You will click... From the official website of the project party mint Button , Open the end-to-end interaction process from the browser to the Ethernet network in detail :

1、 Click on Mint Button

Please log on to the project website ,Chrome Connect your wallet on the , And then click mint Button . Webpage JavaScript The code is project-based mint Price , Contract address, etc raw transaction data , It mainly includes the following key fields

2、TX Signature

Web page code and Metamask Interaction , A window will pop up for you to confirm this transaction . Click ok ,Metamask Will use your wallet private key to sign , To ensure that this transaction is authorized by you , The subsequent Ethereum network will be verified .

3、 send out TX To node verification

transaction TX By Metamask Send to Metamask The Ethereum of node( The default configuration ),node Yes TX check , Ensure that the transaction is not counterfeited .

4、 radio broadcast TX To Ethereum network

transaction TX Sent to neighboring nodes of the Ethereum network , And then broadcast to adjacent contacts . At this time, your transaction can be in etherscan.io You can see , Status is pending state .

5、 The miners node Received TX

The miners node It will be synchronized tx Put them all together Txpool/Mempool place , This place is the key to many things , It needs to be expanded :

Txpool The data source of is mainly from :
Local submission , That is, the third-party application calls the local Ethereum node's RPC Transactions submitted by the service ;
Remote synchronization , It's in the form of broadcast synchronization , Synchronize the transaction data of other Ethereum nodes to the local node ;

Txpool It's a hit Queue and Pending Two queues , First of all, newly received TX It will be judged based on rules and then put into Queue This line , Then add Pending Queue waiting for mining to add new blocks .
 

The main rules are as follows :

1) priority Gasprice high TX
2) Local TX priority , Too remote synchronization
3) Each node will set the minimum Gasprice, Remote below this value TX Will be discarded
Pending Medium TX, By Miner Module gets and validates , For mining ; After successful mining, it is written into the block and broadcast .Miner Take away the deal is copy ,Txpool Medium TX Does not reduce .TX It was written into the chain before it started Txpool Delete .
Gas Too low TX, Will be stuck all the time Txpool Not dealt with , Need can improve Gas Let it be handled .

GasWar: When a hot transaction occurs , Everyone for their own TX Can be prioritized , Strive to improve Gas Fei's scene

6、 The miner pulled out a piece TX Packed

Miners choose TX And then began to mine , Find another block Solution Then broadcast to Ethereum network .

7、 The output block is verified

After verification of other miner nodes , The block is officially linked , We TX The result can be in etherscan.io You can see .

8、TX State synchronization

Relevant status returns to local , Can be in Metamask Found on .

Reference documents :

Life Cycle of an Ethereum Transaction
Transaction lifecycle on the Ethereum blockchain
The Influence Factors on Ethereum Transaction Fees

How the contract is executed

Simply put, the transaction we send will be converted into a Message Object to EVM, and EVM Will be based on Message Generate a Contract Object for subsequent execution . Based on the Data Converted into a contract input call mint function .

NFT Pre sale and public sale

Pre sale can only be purchased for specific users , Public sale means that everyone can rush to buy .
Here we need to answer two technical questions :
1、 How to restrict certain wallets to mint?
2、 How to switch between pre-sale and public sale ?

White list mechanism

The white list is now commonly implemented using the Merkel tree , Simply put, all white list wallet addresses are used as leaf nodes of Merkel tree , Generate a Root hash. You only need to store... In the contract Root hash value , Calling mint Function when the web page JS The code is generated based on the wallet address proof( Parent node of address hash), The contract can verify whether the address belongs to the white list .

With C01 For example :0x6fd053bff10512d743fa36c859e49351a4920df6

At the time of pre-sale and public sale SetRoot to update hash(C01 Both sales are in the form of white list , Public sales shall be conducted by means of capital verification lottery )

Sales status switching

There are two common ways :1) By judging the time point in the contract , such as 2022-01-01 18:00 UTC Start public sale 2) Judge by state , And set the status variable in the contract , For example XRC For example , Judge Status.PublicSale state , This is in the call contract SetStatus Set it up

原网站

版权声明
本文为[NFT practitioner]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206261529207726.html