Internet Computer Basics — Part 2: How to Get Free Cycles to Deploy Your First Dapp

A guide for using the DFINITY Cycles Faucet to access free cycles to pay for IC hosting resources.

Mikhail Turilin
5 min readJun 24, 2022

The second article of the “Internet Computer Basics” series introduces ICP cycles, a payment mechanism that funds canister deployment and execution. Normally, developers need to purchase cycles with ICP tokens. However, each person can receive a one-time donation of ~$20 worth of cycles from the DFINITY Cycles Faucet.

What are ICP cycles?

The Internet Computer blockchain (IC) provides an execution environment for canisters. The Internet Computer consists of hundreds of nodes that are run by Node Providers. Node Providers use infrastructure (CPUs, RAM, and storage) and resources (electricity and network bandwidth) to run the platform. To make the Internet Computer sustainable, developers need to pay for the resources consumed by their canisters.

The Internet Computer uses ICP cycles to determine the resource expenditures. Cycles are not currency. You can use ICP tokens to purchase cycles and transfer them to a container called a “cycles wallet.”

When a canister needs more cycles, a developer can transfer them from the wallet to the canister. Active canisters deployed to the IC continuously burn cycles and need to be “topped-up” to keep working.

Why are cycles different from ICP tokens? This decision was made to ensure that hosting pricing is not volatile while decreasing the risk that building dapps becomes economically infeasible if the ICP token price increases.

Note: Cycles are measured in very large numbers, billions and trillions. When you talk about cycle transfers and replenishment, you will usually operate with trillions of cycles.

What is a cycles wallet?

A cycles wallet holds cycles for a particular user. Under the hood, cycle wallets are canisters and, like all canisters, they run on the Internet Computer. Each user can have multiple cycle wallets if they want to separate cycles in multiple “accounts.”

There are two ways to create cycle wallets:

  1. Use the DFINITY Cycles Faucet to create a new wallet and fund it with free cycles.
  2. Create an empty wallet using terminal commands and fund it through the NNS frontend dapp.

In this guide, we will focus on the first scenario.

Creating a cycles wallet via the DFINITY Cycles Faucet

The easiest way to create a wallet is through the DFINITY Cycles Faucet, which gives you $20 worth of free cycles. The faucet identifies developers using their Twitter accounts to limit cycle donations for each physical person.

Go to https://faucet.dfinity.org and authenticate with your Twitter account:

You will be eligible for 20 trillion cycles, which are more than enough to deploy your first canister:

At the next step, you will see instructions for how to claim cycles:

Let’s take a look at what’s going on here. This command calls a global “cycles wallet” canister using a “well known” address, fg7gi-vyaaa-aaaal-qadca-cai:

$ dfx canister --network=ic call fg7gi-vyaaa-aaaal-qadca-cai redeem '("AAD49-A8CD6-AC4CF")'
(principal "mnwzy-4yaaa-aaaal-qawha-cai")

The value AAD49-A8CD6-AC4CF here is a redemption code generated by the Cycles Faucet. The return value mnwzy-4yaaa-aaaal-qawha-cai here is a principal (the address) of the freshly deployed wallet canister. You can use this canister to store and use your ICP cycles. This canister belongs only to you and will be controlled by the current principal (identity) selected on your machine. You can check the controller of this canister by calling:

% dfx canister --network=ic status mnwzy-4yaaa-aaaal-qawha-cai
Canister status call result for mnwzy-4yaaa-aaaal-qawha-cai.
Status: Running
Controllers: nfxu4-cn7qt-x7r3c-5dhnk-dcrct-gmgoz-67gcg-5glvc-2krhv-gcmsr-qqe
Memory allocation: 0
Compute allocation: 0
Freezing threshold: 2_592_000
Memory Size: Nat(2812290)
Balance: 899_986_569_362 Cycles
Module hash: 0x53ec1b030f1891bf8fd3877773b15e66ca040da539412cc763ff4ebcaf4507c5

The value in the “Controllers” section should be equal to your currently selected principal. To check your current principal you can call:

% dfx identity get-principal
nfxu4-cn7qt-x7r3c-5dhnk-dcrct-gmgoz-67gcg-5glvc-2krhv-gcmsr-qqe

The final step is to set the new wallet as the default for your current identity:

% dfx identity --network=ic set-wallet mnwzy-4yaaa-aaaal-qawha-cai
Setting wallet for identity 'old_identity' on network 'ic' to id 'mnwzy-4yaaa-aaaal-qawha-cai'
Wallet set successfully.

To verify that everything went well, you can check your current wallet by calling:

% dfx identity --network=ic get-wallet
mnwzy-4yaaa-aaaal-qawha-cai

The current wallet setting is stored in your file system in the folder ~/.config/dfx/identity/<identity_name>/wallets.json. For example, on my computer this file looks like this:

{
"identities": {
"old_identity": {
"ic": "mnwzy-4yaaa-aaaal-qawha-cai"
}
}
}

Note: Since ICP cycles are valuable make sure that you backup your identity file in case your computer data is lost. You can find your identity file at the path ~/.config/dfx/identity/<identity_name>/identity.pem.

Now you can check your wallet the balance by calling:

% dfx wallet --network=ic balance
899983799256 cycles.

And now we are done creating a cycles wallet and funding it with some free cycles from DFINITY!

Summary

In this article we explained that ICP cycles are used to pay for IC hosting resources. Cycles wallets are containers that store cycles an implemented as canisters.

We learned how developers can claim free cycles from the DFINITY Cycles Faucet. In the next article, we will see how you can purchase additional cycles with ICP tokens using the NNS frontend dapp.

____

Start building at internetcomputer.org and join the developer community at forum.dfinity.org.

--

--