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

IC Academy » Developer Resources » Deploying a Canister with Cycles

Deploy Your First Canister

Step-by-step guide of spinning up a new canister via the NNS dApp

If you want to learn more about canisters, have a look here: What are Canisters?

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.

To deploy a canister, you need a valid dfx project. Feel free to go ahead by cloning the sample project created by Kyle Peacock who is a Software engineer @DFINITY.

You can clone the sample project via:

Copy to Clipboard

In the next step, get the principle from your computer:

Copy to Clipboard

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.

By entering your principal ID, you authorize your computer to deploy the newly created canister.

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:

Copy to Clipboard

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.json
  • network ic – Flagging the network as the IC
  • no-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:

Copy to Clipboard

Manage Canisters

Learn everything you need to know about managing canister smart contracts on the Internet Computer

More About Managing Canisters

What Are Cycles?

Cycles are the Internet Computer’s computational resource that powers canisters

More about Cycles