Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Who am I?

Open in ICP Ninja

🥷 Try it live — no local setup. ICP Ninja is a web-based IDE that builds and deploys this project to the mainnet for free, right in your browser. Click the badge above, or hit Deploy if you're already in Ninja. To build and run it locally instead, follow the steps below.

Overview

Who am I? demonstrates how entities on the Internet Computer are identified. Every entity, such as a user or canister, has a principal identifier. Principals can be used for identification and authentication. Who am I? uses Internet Identity (II) for user authentication, then displays the principal identifier associated with that Internet Identity on the user interface.

Build and deploy from the command line

Prerequisites

  • Install Node.js
  • Install icp-cli: npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm

Install

Clone the example project:

git clone https://github.com/dfinity/examples
cd examples/rust/who_am_i

Deploy

Start the local network and deploy:

icp network start -d
icp deploy

The frontend is served by the asset canister. To run the Vite dev server with hot reload during frontend development:

npm run dev

When done, stop the local network to free the port and clear state:

icp network stop

Ready to deploy on mainnet?

When you're ready for mainnet, install icp-cli locally and follow the mainnet deployment guide. Mainnet requires ICP tokens and cycles — managing identities securely is much better from your own machine.

Updating the Candid interface

The src/backend/backend.did file defines the backend canister's public interface. The frontend TypeScript bindings are auto-generated from this file during the frontend build.

If you modify the backend's public API, rebuild the canister and regenerate the .did file:

icp build backend
candid-extractor target/wasm32-unknown-unknown/release/backend.wasm > src/backend/backend.did

Security considerations and best practices

If you base your application on this example, it is recommended that you familiarize yourself with and adhere to the security best practices for developing on ICP. This example may not implement all the best practices.