Building with Internet Computer (ICP)
Step-by-Step Guide to Building an Application for Calimero with Internet Computer (ICP)
This tutorial will cover the following topics:
-
Starting a Local Devnet - Setting and configuring a local devnet using dfx through a script.
-
Configuring Nodes - Setting and configuring nodes, installing demo application, creating context and inviting nodes into the context.
-
Installing a Blockchain Demo Application - Setup demo application that contains all functionalities for interaction with smart contracts.
-
Creating a Proposal - Creating a proposal to execute cross-contract call to "Greet" smart contract deployed in step 3.
For easier guidance, we have named each terminal block by their purpose.
Requirements​
To follow this tutorial, you'll need the following:
- Calimero ICP Devnet - Repository
- Calimero Core - Installation instructions - Instructions
- Demo Blockchain Integrations - Repository
You also need following tools:
- Cargo: Version
1.86.0-nightly
used for tutorial - url - DFX (Dfinity SDK): Version
0.24.3
used for tutorial - url - Candid Extractor: Version
0.1.5
used for tutorial - url - Pnpm: Version
9.6.0
used for tutorial - url
Configuring a Local Devnet​
We have prepared a script that will deploy the contracts and create needed accounts on local environment. The script does the following:
- Creates accounts needed for ledger deployment.
- Deploys the context, ledger and example external contract.
- Funds the deployed context contract for initial usage.
- Calls required initial methods on deployed contracts.
Scripts are located in Calimero ICP Devnet repository. First clone the repository.
git clone https://github.com/calimero-network/icp-devnet
cd icp-devnet
chmod +x ./deploy_devnet_addon.sh
The repository contains two scripts:
- Create new dfx environment
- Install on existing dfx environment
deploy_devnet_fresh.sh
- Starts fresh dfx environment and deploys the contracts and needed accounts.
This script will delete the current dfx environment and create a new one.
deploy_devnet_addon.sh
- Deploys the contracts and creates needed account on already existing dfx environment.
dfx environment needs to be started before running this script.
For this tutorial we will be using deploy_devnet_fresh.sh
script.
./deploy_devnet_fresh.sh
=== Deployment Summary ===
Context Contract ID: bkyz2-fmaaa-aaaaa-qaaaq-cai
Ledger Contract ID: bd3sg-teaaa-aaaaa-qaaba-cai
Demo External Contract ID: be2us-64aaa-aaaaa-qaabq-cai
Account Information:
Minting Account: 8b768d662eeebfcbe55b180a7ac0ccb46e2ccd59cacd0b4ec3404f0c8d8b8086
Initial Account: 670183527b941adeae9e1552525853af7812d9441758c668b2e3b8553dead7a0
Archive Principal: kbwrg-ggsyr-4zl47-3z7by-owf4g-draak-xj2ni-mcvwv-6wqxc-nkjam-gae
Recipient Principal: mfefj-dsyoh-rb3b2-3yagk-rvb2p-wcb2v-fhu2n-fel2f-wqzjn-yhtxx-hqe
Deployment completed successfully!
Leave this terminal open as you will need values in later steps.
Context and Proxy Contract​
Context contract​
Calimero context contract is used to create and manage contexts and their members.
More information about context contract can be found here. To see the context contract implementation, refer to the calimero-network/core repository.
Proxy contract​
Proxy contract is used to handle blockchain operations such as cross-contract calls and trasnfers as well as storing variables.
More information about proxy contract can be found here. To see the proxy contract implementation, refer to the calimero-network/core repository. ## Setting up and configuring nodes
By deafult proposal needs 3 approvals before it is executed so we will setup 3 nodes.
- Initialize and start 3 nodes
- Install blockchain demo application
- Create context for blockchain demo application
- Invite all nodes in the same context