Update

Update modified contracts on the testnet

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

YouTube video player
YouTube video player
00:0

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.

1
npm run dev:testnet

You will be asked if you want to use the existing account credentials. Enter Y to continue:

1
? 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:

1
✔ API server started
2
ℹ Kitty Items API is running at: http://localhost:3000
3
ℹ View log output: npx pm2 logs api
4
5
✔ Storefront web app started
6
ℹ Kitty Items Web App is running at: http://localhost:3001
7
ℹ View log output: npx pm2 logs web
8
9
KITTY ITEMS HAS STARTED
10
11
12
Visit: http://localhost:3001
13
14
15
View your account and transactions here:
16
https://testnet.flowscan.org/account/0xa4c19ed9d691743c
17
18
Explore your account here:
19
https://flow-view-source.com/testnet/account/0xa4c19ed9d691743c
20
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.

1
npm run update:testnet

The script will update the changed contract:

1
Deploying 1 contracts for accounts: testnet-account
2
3
KittyItems -> 0x580b8132bc817403 (ba7f...bdc88)
4
5
✨ 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.

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

1
Transaction ID: 60f0271a0ab31173f577300a058d644f5752f1fea844bc1ec6c89eafc8708737
2
3
Status ✅ SEALED
4
ID 60f0271a0ab31173f577300a058d644f5752f1fea844bc1ec6c89eafc8708737
5
Payer 36e0834a80d3a360
6
Authorizers [36e0834a80d3a360]
7
8
Proposal Key:
9
Address 36e0834a80d3a360
10
Index 0
11
Sequence 5
12
13
No Payload Signatures
14
15
Envelope Signature 0: 36e0834a80d3a360
16
Signatures (minimized, use --include signatures)
17
18
Events:
19
Index 0
20
Type A.36e0834a80d3a360.KittyItems.ImagesAddedForNewKind
21
Tx ID 60f0271a0ab31173f577300a058d644f5752f1fea844bc1ec6c89eafc8708737
22
Values
23
- kind (UInt8): 5
24
25
Index 1
26
Type A.7e60df042a9c0868.FlowToken.TokensWithdrawn
27
Tx ID 60f0271a0ab31173f577300a058d644f5752f1fea844bc1ec6c89eafc8708737
28
Values
29
- amount (UFix64): 0.00001000
30
- from (Address?): 0x36e0834a80d3a360
31
32
Index 2
33
Type A.7e60df042a9c0868.FlowToken.TokensDeposited
34
Tx ID 60f0271a0ab31173f577300a058d644f5752f1fea844bc1ec6c89eafc8708737
35
Values
36
- amount (UFix64): 0.00001000
37
- to (Address?): 0x912d5440f7e3769e
38
39
Index 3
40
Type A.912d5440f7e3769e.FlowFees.FeesDeducted
41
Tx ID 60f0271a0ab31173f577300a058d644f5752f1fea844bc1ec6c89eafc8708737
42
Values
43
- amount (UFix64): 0.00001000
44
- 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 before execute{}. 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.