Start developing on the Internet Computer with “Hello, world!”. Learn how entire applications composed of frontend, backend, and data storage, are built using smart contracts.
In this example, you will deploy a simple "Hello, world!" application to the Internet Computer (ICP). This simple example demonstrates how applications on ICP are structured using a backend smart contract and a frontend smart contract, and provides an introduction to the programming language Motoko.
"Hello, world!" projects are a common starting point for developers learning new languages or platforms, as it provides a simple demonstration of how a programming language can be written for an application.
This variation of "Hello, world!" is written in Motoko,a programming language designed specifically for developing smart contracts on ICP. Smart contracts on ICP are called canisters. Motoko strives to be a simple and useful language for ICP canisters that uses a familiar syntax to other languages such as JavaScript, Rust, Swift, or Java.
Every ICP canister must be compiled into WebAssembly before it can be deployed. Motoko's compiler supports compiling to Wasm directly under the hood. It offers seamless integration for ICP features and makes the most out of WebAssembly's functionalities.
The /backend
folder contains the Motoko canister, main.mo
.
The /frontend
folder contains web assets for the application's user interface. The user interface is written using the React framework.
Edit the mops.toml
file to add Motoko dependencies to the project.
In this "Hello, world!" example, the Motoko canister exposes a query
method that can be called to return a "Hello, #name!" message to the user. Query calls are used to return data from a canister, and their response is not validated by consensus.
ICP is the only blockchain that can serve web assets (HTML, CSS, JS, and others) from the blockchain to your web browser. To host these assets, a canister implements a method that accepts and consumes an HTTP request, then returns the web assets in the HTTP response.
In this example, the React frontend is compiled into an asset canister and deployed to ICP.
To communicate with the backend canister, it uses the ICP JavaScript agent.
To migrate your ICP Ninja project off of the web browser and develop it locally, follow these steps.
The BUILD.md
file included in your download will provide information about using dfx
.