Skip to main content
Version: Next

Start

The steps below will help you deploy Cadence smart contracts to the testnet - a hosted Flow blockchain environment for testing. Once deployed, you will spin up local services that interact with your deployed contracts to the testnet.

Video Walkthrough

Start on testnet

To start the project, with all of its services, run the following in the root folder of the project:


_10
npm run dev:testnet

The script will generate new keys and provide instructions to create and fund your new account:


_10
Next steps:
_10
_10
1. Create a new account using the testnet faucet by visiting this URL:
_10
https://testnet-faucet.onflow.org/?key=096..a85&source=ki
_10
_10
2. Copy the new account address from the faucet, and paste it below 👇
_10
⚠️ Don't exit this terminal.

Open up the link to the testnet faucet page, complete the CAPTCHA challenge, and hit Create Account.

Note: This process will take a few seconds. You should see a loading indicator confirming your account is being generated.

Once completed, you will see your new account address (similar to 0x2f915dafac3bd7bf) next to a confirmation that you received 1,000 FLOW tokens. Hit the Copy Address button and return to the terminal and paste your address:


_10
? Paste your new testnet account address here: 0x2f915dafac3bd7bf

Feel free to close the faucet page. Hit enter and the script will complete setting up the project for you. You will see several logs:


_16
ℹ Testnet envronment config was written to: .env.testnet
_16
_16
✔ Contracts deployed
_16
ℹ Contracts were deployed to: 0x9552bb890c4fc6ab (testnet)
_16
_16
✔ Admin account initialized
_16
ℹ ./cadence/transactions/nftStorefront/setup_account.cdc was executed successfully.
_16
ℹ ./cadence/transactions/kittyItems/setup_account.cdc was executed successfully.
_16
_16
✔ API server started
_16
ℹ Kitty Items API is running at: http://localhost:3000
_16
ℹ View log output: npx pm2 logs api
_16
_16
✔ Storefront web app started
_16
ℹ Kitty Items Web App is running at: http://localhost:3001
_16
ℹ View log output: npx pm2 logs web

As indicated in the logs, your account details are stored in a new file: .env.testnet.local. This file will be used whenever you start the service, so you don't have to handle account creation again.

Note: Never commit this file to your version control system - it contains your private key!

Once all services are up and running, you will see the following:


_13
KITTY ITEMS HAS STARTED
_13
_13
_13
Visit: http://localhost:3001
_13
_13
_13
View your account and transactions here:
_13
https://testnet.flowscan.org/account/0xff61db3c65da2fd0
_13
_13
Explore your account here:
_13
https://flow-view-source.com/testnet/account/0xff61db3c65da2fd0
_13
_13
? Would you like to view the logs for all processes? (Y/n)

You will be asked if you want to view logs. These can be helpful if you want to understand better what the processes do. These logs are especially helpful if you face any issues. For now, we can enter n.

Note: If you face issues, you can run npx pm2 logs in a new terminal. The logs will help you troubleshoot any issues you might face. For example, if you already have services running on your machine that use the ports needed, you will be able to see it in the logs.

Congratulations! Your own instance of Kitty Items is now running locally and wired up to the Cadence contracts deployed to the testnet.

Note: If you don't see the success message or if your script does not terminate, take a look at the troubleshooting FAQs.

Open Kitty Items

Open up the web application by visiting http://localhost:3001. It should look like this:

welcome-ui

As a first step, you can try minting your first NFT, aka a Kitty Item. Click on the "Mint your first Kitty Item" button. You will be prompted to enter a password:

admin-login

Enter KittyItems and hit "Log In". You should see the admin dashboard:

admin-ui

Now, hit the "Mint Item" button and see a new NFT being generated.

Note: Not able to mint a Kitty Item? Take a look at the troubleshooting FAQs.