Developer Resources
Deploying a Canister with Cycles
Find out how you can deploy a canister smart contract on the Internet Computer via the NNS front-end dApp
Deploy Your First Canister
Step-by-step guide of spinning up a new canister via the NNS dApp
Prerequisites
The following guide will show you how you can spin up a canister smart contract via the NSS front-end dApp. To do so, you need the following:
Once you’ve prepared everything, we can jump right into it.
Creating a canister
Log into the NSS front-end dApp via https://nns.ic0.app. Once you’re logged in, navigate to the Canisters
tab that you can find at the top on the right-hand side.
In the next step, click on Create or Link Canister
and Create New Canister
and select your wallet.
The interface will now ask you to enter a given amount of ICP or Cycle. The minimum amount is 2T (2 trillion) Cycles, which includes a fee of 1T Cycles if you create a new canister.
Click on Review Cycles Purchase
to verify everything is correct and Confirm
to create the canister.
Connecting Your Computer
Authorizing the dfx on your computer
Once you have finished the preparations and created a canister, you can go ahead with the following steps.
You can clone the sample project via:
In the next step, get the principle from your computer:
Copy the ID. You can now return to the NNS front-end dApp with your new canister. Select Change Controllers
to manage your controllers.
Enter the principal ID you have just copied in the empty field and click on Perform Controller Change
.
If everything is correct, confirm the changes by clicking on Yes, I'm Sure
. Once confirmed, you can copy your canister ID.
Deploying Your Canister
Spinning up a new canister via the NNS dApp
To deploy your first canister, open the sample project and switch to the canister_ids.json
file. Insert your canister ID where it says <canister-id>
inside the quotes and save the file.
Once that’s done, run the following:
This deploys an asset canister. You can find its index.html
file by navigating to /assets
. Doing so deploys the sample website to the Internet Computer.
Command breakdown
Here’s a breakdown of the command:
dfx deploy
– This deploys the project by using the config specified in dfx.jsonnetwork ic
– Flagging the network as the ICno-wallet
– Deploying directly to an existing canister instead of a new wallet
Testing your successful deployment
After you have run the command, you can test if the deployment has been successful by visiting the following URL: canister-id.ic0.app
where canister-id
is your canister ID.
You can redeploy with the same command: