Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Who am I?

View this sample's code on GitHub

Overview

Who am I? demonstrates how entities on the Internet Computer are identified. Every entity, such as a user or canister smart contract, 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/motoko/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, regenerate the .did file using the Motoko compiler:

$(mops toolchain bin moc) --idl -o src/backend/backend.did src/backend/main.mo

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.