In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Today, I will talk to you about how to create and deploy NFT smart contracts in 10 minutes. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something from this article.
What is NFT?
NFT stands for irreplaceable tokens, for example, a dollar bill is replaceable because you can exchange it for another dollar bill (and you don't have to worry about the serial number of the dollar bill). Similarly, Bitcoin is an alternative token because two different bitcoins are exactly the same.
In that case, the irreplaceable things are the only things that cannot be interchanged with other things. Irreplaceable tokens are essentially the only tokens tracked on the blockchain.
Irreplaceable tokens have the following characteristics:
They are unique: each irreplaceable token represents a number or an object in the real world, and is unique even if a similar object exists. For example, even if someone "creates" 100 of the same works of digital art as NFT, each will be tracked separately on the block chain.
They are verifiable: the historical ownership of these NFT is recorded in the public ledger and can be seen by everyone. This makes it difficult to copy and relatively simple to prove authenticity.
They are tradable: like other encrypted assets, they are tradable, although they are usually traded on special exchanges.
Most NFT are built on the ethernet block chain, and irreplaceable NFT is all the rage these days, and as a developer, you may want to know how to create your own NFT. This article explains how to do this in the easiest way so that you can get up and running in just a few minutes.
We will use the standard OpenZeppelin ERC721 contract, which is the gold standard for smart contracts. There are many tools for deploying smart contracts, but in this article, we will use the web3 CLI tool because it is the fastest and easiest tool to compile and deploy contracts.
Build an environment
In F? Llowing stuff just has to be done once, and then it can be deployed and interacted like you don't want to do it again.
1. Install CLI tools
This liner will install the tool, so you can start using it immediately. If you are worried about the function of install.sh, please feel free to read it.
Curl-LSs https://raw.githubusercontent.com/gochain/web3/master/install.sh| SH
two。 Set up the network
We will use GoChain here, so we don't have to pay $10 to deploy the contract, and then invest $10 per NFT. With GoChain, we only pay a fraction of a penny and are 100% compatible with Ethernet Square, so we can use it like Ethernet Square. Of course, you can change the following line to point to Ethernet Square and pay an additional fee as needed.
Export WEB3_NETWORK=gochain # for ethereum: # export WEB3_NETWORK=ethereum
3. Add / get gas
You will need to use a with some gas supply to make these transactions, or to create a new gas supply for its use. This will be $GO on GoChain or $ETH on Ethernet Square.
To create a new account, run:
Web3 account create
This will print:
Private key: 0xABC123 Public address: 0xXYZ456
Send some $GO to "public address". If you need to get started with some $GO, please enter our telegram and ask, where someone will well send you a $GO or two.
Copy the Private key (or use the existing private key as needed) and run:
Export WEB3_PRIVATE_KEY=0xABC123
In addition, please keep a copy of this private key in a safe place for next use.
Deployment work
Now that we have set up the netset and have some refueling keys in our private key, we can start to have fun.
Create a contract
The WEB3 CLI has built-in code generators for common contracts such as ERC20 and ERC721. Run quickly:
Web3 generate contract erc721-symbol KATS-name "Krypto Kats"-base-uri https://kryptokats.com/token/
This will generate a file called KATS.sol, which is the unified program for your new NFT contract.
1. Deployment contract
From here, we just need to compile and deploy it. Similarly, web3 CLI makes this part easier:
Web3 contract build KATS.sol web3 contract deploy KATS.bin
This will print out your new contract address. You have now deployed the NFT contract!
Now that the contract has been deployed, we just need to create a new contract. When casting a NFT, you need to provide the address of the person who owns this new NFT:
Web3 contract call-wait-abi KATS.abi-gas-limit 2000000-function mint 0xABC
This feature produces a completely new NFT and assigns it to the address 0xABC. ERC721's new OpenZeppelin preset has an automatically incrementing ID, so you will see the new token ID in the output. For example:
Parsed Logs: [{"name": "Transfer", "fields": {"from": "0x00000", "to": "0x000ABC", "tokenId": "0x00001"}}]
The output has been truncated with a stack of zeros removed, but you can see that the new token ID is number 1.
Transfer NFT
Now, if you own NFT and want to transfer it, you can call the transferFrom function:
Web3 contract call-wait-abi KATS.abi-gas-limit 2000000-function transferFrom 0xABC 0xXYZ 1
This transfers the token with an ID of 1 to the new owner 0xXYZ located. You can view and search for tokens in GoChain Explorer.
After reading the above, do you have any further understanding of how to create and deploy NFT smart contracts in 10 minutes? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.