Demo 1: Creating NFTs on Theta Blockchain with Remix
This guide will provide a walkthrough of creating your first NFT on Theta blockchain uising Remix with the Theta web wallet. To see the process in action, you can also watch Theta CTO Jieyi Long's presentation here.
First, access the example NFT contract found on Theta GitHub.
Next, compile the source code in a compiler like Remix. Create a new file in Remix (in the example, “newNFT.sol”), then copy the source code from GitHub to your Remix file and save it.
Now switch to the compiler tab and select the proper compiler version, 6.2. Language should be Solidity, and the EVM version ‘compiler default’. Enable optimization and leave at 200. Click Compile nft.sol. In the contract dropdown, then select CoolNFT from the various contract options.
Now to deploy the contract by going to the Theta Wallet.
Login to your Theta Wallet that has at least 5 TFUEL (deploying a Theta smart contract takes about 2.5 TFUEL, and contract interactions around 0.1 TFUEL). Click to the Contract section and we will use the Deploy Contract side. Two inputs, the ABI/JSON interface and the Byte Code, both of which you can get from the compiled code in Remix. Click the small copy button next to ABI and then paste it in the ABI/JSON field of the Theta Wallet. Similarly, click the small copy button next to ‘Bytecode’ in Remix and then paste that info to the ABI section of Theta Wallet. In the Constructor Inputs section, enter the name of your NFT, the symbol/ticker you want to use for it, and the URL of the GIF or other image you want to represent your NFT. Then, click Deploy Contract and enter your wallet password to deploy the contract.
Your contract has now been deployed at the address displayed. The Theta wallet has switched over to the Interact with Contract section, where you can use various Functions built into the contract from the dropdown menu.
You can also inspect the deployed contract by entering the contract address in the Theta Explorer.
To read the contract Theta Explorer, scroll down to the Code section once again paste the contract source code where it says “Enter the Solidity Contract Code below”. You’ll also need to select Compiler Version 6.2 and ‘Optimization: Yes” to match Remix compiler. Then, click the ‘Verify and Publish’ button at the bottom.
Now that your smart contract code is published on Theta Explorer, click Read Contract in the Theta Explorer to confirm the parameters set and query the address where the token is stored. To transfer the NFT, go to the Theta Wallet and choose the transferFrom function. Enter the address you are transferring from, to, and the tokenid (0). By checking that address we can find the transaction we just sent, and can see that our NFT was transferred successfully, using either the Theta Explorer or the Theta Wallet you deployed the contract from:
For less technical users who want to create NFTs on Theta blockchain, an NFT minter and other user-friendly tools are also in the works. You can also join the Theta Developers channel in the Theta Discord.
Updated about 3 years ago