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...