The content covered in this article is based on the DFINITY Canister SDK, which differs from the NNS system in that they have a different account system.
The Internet Computer blockchain enables multiple computers to operate as one very powerful virtual machine. The computers that make up a virtual machine are organized into subnetworks, each of which is a blockchain consisting of a certain number of independent machines (peer-connected computers called nodes) that run the software components of the Internet Computer protocol.
The Internet computer software components running on each node are called replicas, and they replicate state and computation among all nodes in the subnetwork blockchain, and the core components of the replicas are organized into the following logical layers:
With Internet Computer, developers can focus on writing code using smart contracts without similar distractions associated with the environment, such as:
Actor: An actor is a special object in modern programming languages that handles messages in an isolated state, allowing them to be processed remotely and asynchronously.
Usually, each canister contains the compiled code of an actor object. Each canister also contains some additional information, such as an interface description or front-end assets. It is possible to create projects containing multiple canisters, but each canister can only contain one Actor.
A canister is an object with a common unique identifier similar to the concept of a smart contract that defines the owner of a specific application, service, or microsite.
The canister encapsulates all programming logic, public entry methods, interface descriptions that provide message types, and state information for the application or service, or microservice.
When calling functions by sending messages to the canister entry point, there are two types of calls: Query calls (non-committed query calls): allow calling functions that query the current state of the container or call functions that operate on the container state but do not change it. Has the following characteristics:
Controller is an identity with special privileges that are used to manage the canisters it controls. only the controller identity can be used to install, upgrade, or remove the canisters it controls.
The controller identity can be specified using the principal identifier associated with the user or canister.
The ledger Internet Computer records all transactions involving ICP tokens in an administrative canister called the ledger canister. ledger canister is a simplified parallel blockchain that runs in a subnet of Internet computers along with other network administrative canisters.
The ledger canister implements a smart contract that holds accounts and balances and keeps a history of transactions that affect them. Recorded transactions are used to track specific events such as:
Principal: The first time you use the DFINITY Canister SDK, the dfx command line tool creates a default developer identity for you using the public/private key pair from the PEM file. The developer identity is represented by the derived principal data type and the text representing the principal, also known as the principal identifier.
The developer identity can also be used to derive an account id (similar to a bitcoin or ethereum address) for holding ICP tokens in the ledger canister.
Wallet: On Internet Computer, a wallet is an application dedicated to cycle. The wallet application is implemented as a canister and runs on an Internet computer.
A wallet enables you to manage cycle balances, convert ICP tokens to cycles, and distribute cycles to your own or other users' canisters as a way to access or provide Internet services.
When a canister needs to be created or manipulated, a wallet canister must be bound to the current subject identifier before the operation can take place.
Smart contract: A smart contract is software that allows the execution of trusted transactions and agreements on a distributed, decentralized blockchain network without the need for any central authority or the legal system.
With a smart contract, the terms of the transaction or agreement are written directly into lines of code that are executed on the blockchain network. The code controls execution and the transaction is tamper-proof, traceable, and irreversible. On Internet computers, smart contracts are deployed into canisters.
WebAssembly WebAssembly (Wasm) is an underlying computer instruction format. Because WebAssembly defines a portable, open-standard binary format that can be clearly abstracted on most modern computer hardware, it is widely supported by programs running on the Internet. Programs written in Motoko are compiled into WebAssembly code for execution on a copy of an Internet computer.
Replica: In the context of the Internet Computer Blockchain, replica refers to an Internet Computer process running on a physical computer node in the network.
For the DFINITY Canister SDK, use the dfx start and dfx stop commands to start and stop replica processes locally, providing a local network for development.
Some of the account operations in the whole IC are as follows:
Local development
Network deployment
When the command dfx new hello is used, a directory with the following structure is created:
hello/
├── README.md # default project documentation
├── dfx.json # project configuration file
├── node_modules # libraries for front-end development
├── package-lock.json
├── package.json
├── src # source files directory
│ ├── hello
│ │ └── main.mo
│ └── hello_assets
│ ├── assets
│ │ ├── logo.png
│ │ ├── main.css
│ │ └── sample-asset.txt
│ └── src
│ ├── index.html
│ └── index.js
└── webpack.config.js
Among them:
Dfx configuration file: When using the command dfx new hello, the dfx.json project configuration file with the following content will be created:
{
"canisters": {
"hello": {
"main": "src/hello/main.mo",
"type": "motoko"
},
"hello_assets": {
"dependencies": [
"hello"
],
"frontend": {
"entrypoint": "src/hello_assets/src/index.html"
},
"source": [
"src/hello_assets/assets",
"dist/hello_assets/"
],
"type": "assets"
}
},
"defaults": {
"build": {
"packtool": ""
}
},
"dfx": "0.7.2",
"networks": {
"local": {
"bind": "127.0.0.1:8000",
"type": "ephemeral"
}
},
"version": 1
}
Where:
Author: Leo
Figure from: Developer Experience (DX) and the Internet Computer
Also published here.