Creating the NFT smart contract
Let’s create an NFT smart contract named HelloNFT
. You can reuse the project directory you’ve created.
The smart contract code is quite long. You can get the smart contract from this URL: https://github.com/PacktPublishing/Hands-On-Blockchain-for-Python-Developers--2nd-Edition/blob/main/chapter_13/nft/contracts/HelloNFT.vy. The code looks like this:
#pragma version ^0.3.0 # Adapted from https://github.com/vyperlang/vyper/blob/master/examples/tokens/ERC721.vy from vyper.interfaces import ERC165 from vyper.interfaces import ERC721 implements: ERC721 implements: ERC165 event Transfer: _from: indexed(address) _to: indexed(address) _tokenId: indexed(uint256) ... @view @external def tokenURI(tokenId: uint256) -> String[132]: return concat(self.baseURL, uint2str(tokenId))
You can download the smart contract file and put it inside the contracts...