ICP Developer Guide -Chapter 2

The Building Block of ICP-Canister

Canister is a fundamental computational unit that combines both code and state. It is essentially a smart contract or a container that runs on the Internet Computer blockchain. Canisters are designed to be autonomous, scalable, and interoperable, enabling developers to build decentralized applications (dApps) and services.

Key Features of a Canister:

Code and State:

  1. Autonomous:
    • Canisters operate independently and can interact with other canisters or external systems via messages.
  2. Scalable:
    • The Internet Computer allows canisters to scale horizontally by distributing their workload across multiple nodes in the network.
  3. Interoperable:
    • Canisters can communicate with each other through message passing, enabling complex decentralized applications to be built by composing multiple canisters.
  4. Upgradable:
    • Developers can update the code of a canister without losing its state, making it easier to maintain and improve applications over time.

Cycle

n the Internet Computer (ICP), a Cycle is a computational unit used to pay for the execution of smart contracts (called canisters). It functions similarly to “gas” in Ethereum but is designed to be more predictable and cost-efficient.

Key Features of Cycles in ICP:

  1. Resource-Based Pricing – The cost of computation, storage, and network usage is measured in cycles.
  2. Stable Pricing Model – Unlike Ethereum’s gas, the cost of cycles is tied to real-world resources (compute and storage) rather than being market-driven.
  3. Conversion from ICP Tokens – ICP tokens can be converted into cycles to fund canister execution. The conversion rate is adjusted to maintain price stability. XDR (Special Drawing Rights) is used as a reference unit to determine the cost of converting ICP tokens to cycles in a stable manner.(1T Cycle = 1 XDR ~ USD1.321)
  4. Canister Management – Cycles are stored within canisters and consumed as operations are performed. When a canister runs out of cycles, it stops executing until refueled.

Cycle Usage in ICP:

  • Computation – Each instruction executed by a canister consumes cycles.
  • Storage – Data stored in the canister costs cycles over time.
  • Inter-canister Calls – Messaging between canisters also consumes cycles.
  • Network Operations – Data transmission to and from the Internet Computer incurs cycle costs.

Creation of a Cycle Wallet in Local Network

To create a cycle wallet in the local network, you start the local network in a clean mode using the following command:

dfx start –background –clean

Running the following command first time to create a cycle wallet automatically with 100T cycles in local network, otherwise it will return the cycle wallet id only.

dfx identity get-wallet

The following command will return the balance in the wallet:

dfx wallet balance

Motoko-The native programming language of ICP

Motoko is a programming language specifically designed for the Internet Computer (ICP) blockchain. It is optimized for writing smart contracts (called canisters) that run directly on the ICP network.

Key Features of Motoko

  1. Actor-Based Model – Uses the actor model to handle concurrency and asynchronous execution efficiently.
  2. Type-Safe & Memory-Safe – Strongly typed language that prevents common programming errors.
  3. Designed for Web3 – Integrates directly with the Internet Computer, supporting scalability, persistence, and seamless upgrades.
  4. Automatic Garbage Collection – Handles memory management internally.
  5. WebAssembly Compilation – Runs as WebAssembly (Wasm) for efficient execution on the ICP blockchain.
  6. Interoperability – Can interact with Rust, JavaScript, and other WebAssembly languages.

Create and Deploy Canisters

Creating a canister on the Internet Computer (ICP) involves a few simple steps. Below is a basic guide:

Start local network in background

dfx start –background

Create hello world project

dfx new hello

Select a backend language, you may choose Motoko, Rust, Python or Typescript, as shown below. We choose Motoko for our illustration.

Then select a Frontend language as follows. We choose React for illustration.

Then add extra features as follows, we choose Intenet Identity:

Pressing enter to confirm will create all necessary files and install dependencies, and arrive at the start up screen as shown below. A project with the folder name hello will be created.

The project architecture is as shown below:

Deploying Canister on Local Network

To deploy the hello project you have just created on a local network, use the following command:

dfx deploy

The following screen shows successful deployment, otherwise there will be errors:

You may access the frontend URL via the link generated.

The frontend UI is as illustrated below:

Deploying Canister on the IC Mainnet

The command to deploy the canister on the IC mainnet is

dfx deploy –network ic

If the deployment on the IC blockchain is successful, the output will display the URLs of both the frontend and backend, as shown below:

The frontend URL can be accessed on the desktop browser and the browser of the mobile devices. It does not need to register a domain nor a central server to host the web app, it is fully on chain.

In this example, accessing the frontend URL with the link will display a certificate generator app, as shown below:

Obtaining Cycles

You need cycles to deploy your ICP app on the mainnet. There are two ways to obtain the cycles, one way is to redeem the coupon codes if you are given some free coupons, the other way is to buy icp tokens and convert them to cycles.

Method 1: Redeeming cycles from coupon codes

The command to redeem the cycles with coupon code is as follows:

dfx cycles redeem-faucet-coupon –network ic <COUPON_CODE>

Example: dfx cycles redeem-faucet-coupon –network ic CE3A9-BA578-CD44B

To check cycles balance in the wallet, use the following command:

dfx cycles –network ic balance

Method 2: Converting ICP tokens to cycles

First of all you must create an empty canister using ICP token using the following command:

dfx ledger –ic create-canister <principal-identifier> –amount <ICP tokens>

You may use the following command to obtain the principal identifier:

dfx identity get-principal

Example to get the principal identifier:

Then use the following command to convert ICP tokens to cycles:

dfx ledger –ic create-canister zxyfn-yljyi-bn6dy-ixi7n-jez74-nk723-pvj3m-jykes-dhqon-3ktql-uae –amount 0.3

To check canister status on the mainnet, use the following command:

dfx canister –network ic status <canister_id>

The status is as shown below:

*You can obtain canister id on the ic mainnet using the command: dfx canister id <canister name>–network ic

Appendix: List of dfx commands

List all accounts in the device

dfx identity list

Show current identity

dfx identity whoami

Use a particular identity

dfx identity use <Identity Name>

Get ICP Tokens balance

dfx ledger balance

Top up cycles into cycle wallet or canister by converting ICP Tokens

dfx ledger –network ic top-up <wallet id or canister id> –amount <icp tokens>

Example: Add 4T cycles to your backend canister

dfx ledger top-up –network ic <canister_backend >–amount 4.0

Top up cycles directly

dfx canister –network ic deposit-cycles amount <canister_backend>

Example: Deposit 4T cycles to your backend canister

dfx canister –network ic deposit-cycles 4000000000000 weather_app_backend

To remove your identity in the device

dfx identity remove <identity name>

To get canister basic info

dfx canister –network ic info

To stop local network

dfx stop

To list the controllers of the canister:

dfx canister info ic_minter_backend

ICP Developer Guide -Chapter 1

In the previous post, you learned about the fundamental concepts of the Internet Computer Protocol (ICP), a third-generation blockchain designed to power the next evolution of the internet. At its core, ICP functions as a decentralized cloud, enabling developers to build and deploy applications entirely on-chain without relying on traditional centralized servers like AWS or Google Cloud.

You might be wondering—how is this even possible? To clear up any doubts, I will walk you through the process of creating and deploying an application on the Internet Computer. Unlike conventional web hosting, ICP allows you to launch apps without registering a domain name or provisioning a cloud server, leveraging blockchain-native web hosting for a truly decentralized experience.

Prerequisite

To start coding in IC(Internet Computer) , there are some prerequisites you need to set up or install before you can jump into developing your first app. Following are the prerequisites:

  • Ensure you have the supporting operating system-
    • Windows 10 or 11 with WSL2 installed with Ubuntu Linux v20.04
    • Mac OSX 12 or above
    • Ubuntu Linux v20.04
  • NodeJs v20
  • GitHub Account
  • IC SDK
  • Visual Studio Code IDE
  • Basic programming knowledge- JavaScript, CSS, HTML

Here are the references to install the or set up the prerequisites:

You must install IC SDK before you can start coding. Use the following command in the WSL ubuntu terminal to install the SDK:

·sh -ci “$(curl -fsSL https://internetcomputer.org/install.sh)”

After installation, check its version using the command dfx –version, you should see something like dfx 0.24.3

*·If you are using a machine running Apple silicon, you will need to have Rosetta installed. You can install Rosetta by running softwareupdate –install-rosetta in your terminal.

The next step is to create an account in IC. In ICP, authentication requires a key pair consisting of a private and a public key, while the account itself is identified by a unique principal ID. Additionally, a ledger is needed to store accounts and transactions. This ledger is a smart contract known as a system canister. Each user will have a ledger account identifier, also called an account ID, which is used to hold ICP tokens. Furthermore, a wallet must be created to store cycles and facilitate sending cycles to and from canisters.

Creating ICP Account

To create an account in IC, using the following command:

dfx identity new <identity_name>

·💡Identity names must use alphanumeric characters comprising uppercase and lower letters, numbers and special characters. Example: My_chatb@t

·ℹ️Most importantly, REMEMBER to back up the 24-word account/identity seed phrase. This is essential for restoring your account if you forget your password or need to access it from another device. Additionally, you can create multiple accounts on your device.

Principal ID

Having created your account, you can obtain your principal id using the following commands:

dfx identity use <identity_name>

dfx identity get-principal

Your account’s principal ID will resemble this:

zxyfn-yljyi-bn6dy-ixi7n-jez74-nk723-pvj3m-jykes-dhqon-3ktql-uae

Ledger Account ID

You can also obtain your ledger account id using the following commands:

dfx identity use <identity_name>

dfx ledger account-id

Your Ledger account ID will resemble this :

1370f0ea74b35f33d2a2fee64a7a8c53cd52d6dd82c1cdfe08712dcd863692ab

Importing Account

In case you have changed your device and need to use the same account to develop ICP apps, you may import the 24-word seed phrase you have saved as a plaintext into your new development environment using the following command:

dfx identity import –seed-file <seedfile.txt> <Identity Name>

ICP Token Balance

To check the ICP token balance in ledger account on ICP Main Network, use the following commend:

dfx ledger –network ic balance

·💡–network ic or –ic: Connect to ICP Main Network, without this parameter, it will connect to the local network

Internet Identity

Internet Identity is a decentralized authentication system for the ICP. If you haven’t already, set up an Internet Identity:

  • Go to the Internet Identity portal: https://identity.ic0.app/.
  • Click “Create New” to create a new identity.
  • Follow the prompts to register your device . For Windows 10 user, require to use your mobile phone to scan the QR Code to store the credential information in the mobile phone. For Android device, recommend to use Google Lens to perform Passkey QR code scanning.
  • Note down your Internet Identity number (e.g., 12345).

 ICP Account Address

To receive ICP tokens, you need an ICP account address associated with your Internet Identity. Here’s how to get it:

  • Go to the Network Nervous System (NNS) Dapphttps://nns.ic0.app/.
  • Authenticate using your Internet Identity.
  • Once logged in, navigate to the “Accounts” section.

Plug Wallet

You may also use the Plug Wallet to store your ICP tokens. Plug wallet can be installed as a browser extension on a laptop or can be installed as a mobile app on your phone. You can download Plug Wallet using the link below.

https://plugwallet.ooo/

Network Nervous System

The Network Nervous System (NNS) is the decentralized governance system aka DAO that controls and manages the Internet Computer (ICP), a blockchain-based computing platform developed by the DFINITY Foundation. The NNS is one of the most critical components of the Internet Computer, as it enables the network to operate autonomously and evolve over time through community participation.


Key Functions of the NNS

  1. Governance:
    • The NNS allows ICP token holders to participate in the governance of the Internet Computer by submitting and voting on proposals.
    • Proposals can cover a wide range of topics, such as upgrading the protocol, adjusting network parameters, or funding ecosystem projects.
  2. Token Economics:
    • The NNS manages the ICP utility token, including its minting, burning, and distribution.
    • It also handles the creation of cycles, which are used to pay for computation and storage on the Internet Computer.
  3. Node Management:
    • The NNS oversees the addition, removal, and configuration of node machines that power the Internet Computer.
    • It ensures the network remains secure, scalable, and efficient.
  4. Canister Management:
    • The NNS manages the lifecycle of canisters (smart contracts) on the Internet Computer, including their creation, upgrading, and deletion.
  5. Network Upgrades:
    • The NNS facilitates seamless upgrades to the Internet Computer protocol without requiring hard forks or downtime.
    • This is achieved through a decentralized voting process.

What is ICP Blockchain? A Brief Introduction


The Internet Computer Protocol (ICP) is a groundbreaking blockchain technology developed by the DFINITY Foundation. Often referred to as the third generation of blockchain, ICP aims to transform the way the internet works by allowing it to natively host software, smart contracts, and web services — all directly on the blockchain.

What Makes ICP Unique?

Unlike traditional blockchains that rely on external cloud services or centralized web servers, ICP enables developers to build fully decentralized applications (dApps) that run 100% on-chain. This is a major leap forward in creating a truly open, secure, and tamper-proof version of the internet.

ICP does more than just support cryptocurrencies or DeFi — it provides the infrastructure for building entire systems and platforms, including websites, enterprise software, and social media apps, directly on the blockchain.

How Does It Work?

ICP operates through a global network of independent data centers that run specialized nodes. These nodes are organized into subnets, each capable of hosting canisters — a new kind of smart contract optimized for performance and scalability.

The protocol uses advanced cryptography, including Chain Key Technology, to manage, validate, and synchronize data across the network at web speed. This makes ICP one of the fastest and most scalable blockchains in existence.

Key Features of ICP:

  • Decentralized Hosting: Apps run entirely on the blockchain, eliminating the need for centralized web hosting.
  • Web Speed Performance: Processes transactions and updates data in seconds.
  • Smart Contract Canisters: Advanced, upgradeable smart contracts that scale horizontally.
  • No Middlemen: Users interact directly with dApps through any browser — no need for plugins or wallets.
  • Governance via NNS: The Network Nervous System (NNS) governs upgrades, configurations, and economics of the Internet Computer.

Real-World Use Cases

ICP is already powering a wide range of innovative projects:

  • OpenChat: A decentralized alternative to WhatsApp.
  • DSCVR: A blockchain-based social network similar to Reddit.
  • Internet Identity: A secure, anonymous authentication system without usernames or passwords.

Startups, enterprises, and developers are using ICP to build next-generation services that are censorship-resistant, interoperable, and cost-effective.

The Role of the DFINITY Foundation

Founded in Zurich, Switzerland, the DFINITY Foundation is a not-for-profit organization behind the Internet Computer. With one of the largest R&D teams in blockchain, DFINITY is committed to building an internet that’s open, secure, and owned by its users — not centralized corporations.


Final Thoughts

ICP isn’t just another blockchain. It’s a bold vision of the future — a new internet where apps and data live on a public, decentralized infrastructure. Whether you’re a developer, investor, or curious tech enthusiast, keeping an eye on ICP could mean witnessing the next big leap in the evolution of the web.


Refer to ICP Overview for further reading.