Update
In the first step of this tutorial, you started the project on the testnet. The script uploaded the initial contracts on the network for you.
Now that you implemented and tested your changes locally on the emulator, it is time to deploy your modified smart contracts to the testnet.
Video Walkthrough
Start on testnet
Run the project on the testnet again. The script will use the account you initially created:
Important: You do not need to stop the previous process. By running the next command, existing services will be configured to communicate with the testnet instead of the emulator.
_10npm run dev:testnet
You will be asked if you want to use the existing account credentials. Enter Y
to continue:
_10? Use existing testnet credentials in env.testnet ? (Y/n) Y
Once all services are up and running, you will see the same logs you saw in the second step:
_21✔ API server started_21ℹ Kitty Items API is running at: http://localhost:3000_21ℹ View log output: npx pm2 logs api_21_21✔ Storefront web app started_21ℹ Kitty Items Web App is running at: http://localhost:3001_21ℹ View log output: npx pm2 logs web_21_21KITTY ITEMS HAS STARTED_21_21_21Visit: http://localhost:3001_21_21_21View your account and transactions here:_21https://testnet.flowscan.org/account/0xa4c19ed9d691743c_21_21Explore your account here:_21https://flow-view-source.com/testnet/account/0xa4c19ed9d691743c_21_21? Would you like to view the logs for all processes? (Y/n)
Open up the last link to explore your testnet account via flow-view-source. On the left side navigation, locate the Kitty Items contract.
Keep this page open - we will get back to it once we are done!
Update contract on the testnet
Next, redeploy the contracts to the testnet by running the following command in your terminal, inside the root folder of your project:
Note: You will notice that the previous script execution finished once all services successfully started. You do not need to stop the previous process. You can run the next command in the same terminal without impact on the services running in the background.
_10npm run update:testnet
The script will update the changed contract:
_10Deploying 1 contracts for accounts: testnet-account_10_10KittyItems -> 0x580b8132bc817403 (ba7f...bdc88)_10_10✨ All contracts deployed successfully
Note: You may notice that this time only one contract was updated. This is because the other 3 contracts were already deployed outside of this project.
Go back to the flow-view-source page and refresh the contract view. Scroll down verify the changes you made to your contract. For instance, you should see shades
case in the Kind
enum.
Run the update transaction on the testnet
Finally, run the following command to send the transaction to update the contract with the new shades
images on the testnet.
_10npx dotenv -e .env.testnet -- flow transactions send --signer testnet-account ./cadence/transactions/kittyItems/add_nft_images_for_new_kind.cdc -f flow.json -f flow.testnet.json -n testnet
You should see the following response. Take note of the Status - it should be ✅ SEALED
.
_45Transaction ID: 60f0271a0ab31173f577300a058d644f5752f1fea844bc1ec6c89eafc8708737_45_45Status ✅ SEALED_45ID 60f0271a0ab31173f577300a058d644f5752f1fea844bc1ec6c89eafc8708737_45Payer 36e0834a80d3a360_45Authorizers [36e0834a80d3a360]_45_45Proposal Key:_45 Address 36e0834a80d3a360_45 Index 0_45 Sequence 5_45_45No Payload Signatures_45_45Envelope Signature 0: 36e0834a80d3a360_45Signatures (minimized, use --include signatures)_45_45Events:_45 Index 0_45 Type A.36e0834a80d3a360.KittyItems.ImagesAddedForNewKind_45 Tx ID 60f0271a0ab31173f577300a058d644f5752f1fea844bc1ec6c89eafc8708737_45 Values_45 - kind (UInt8): 5_45_45 Index 1_45 Type A.7e60df042a9c0868.FlowToken.TokensWithdrawn_45 Tx ID 60f0271a0ab31173f577300a058d644f5752f1fea844bc1ec6c89eafc8708737_45 Values_45 - amount (UFix64): 0.00001000_45 - from (Address?): 0x36e0834a80d3a360_45_45 Index 2_45 Type A.7e60df042a9c0868.FlowToken.TokensDeposited_45 Tx ID 60f0271a0ab31173f577300a058d644f5752f1fea844bc1ec6c89eafc8708737_45 Values_45 - amount (UFix64): 0.00001000_45 - to (Address?): 0x912d5440f7e3769e_45_45 Index 3_45 Type A.912d5440f7e3769e.FlowFees.FeesDeducted_45 Tx ID 60f0271a0ab31173f577300a058d644f5752f1fea844bc1ec6c89eafc8708737_45 Values_45 - amount (UFix64): 0.00001000_45 - inclusionEffort (UFix64): 1.00000000_45 - executionEffort (UFix64): 0.00000012
As indicated, the transaction was sealed and you are ready to mint your new KittyItems NFT on the testnet!
🎉 Congratulations on completing this tutorial! Because you made it to the very end, we're rewarding you with a unique FLOAT NFT!
Important: To claim your NFT, open this FLOAT event. You will be asked to connect a wallet. Once done, you need to enter a secret code. Open the
add_nft_images_for_new_kind.cdc
file you created in this previous step. Locate the comment beforeexecute{}
. Use this code to claim your NFT 🤫
To summarize, you should now understand how to ...
- deploy and update smart contracts
- mint and transfer NFTs
- add a new kind of NFT to the marketplace
- interact with the Flow blockchain from within a web application
Optional: Mint new sunglasses NFT on testnet
To verify that everything works as expected, you can mint one of the new NFTs on the testnet.
Open the Kitty Items web application: http://localhost:3001/
. This time, the web application is wired up to interact with testnet smart contracts you updated. Repeat the instructions from the last step.