🥷 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.
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.
Clone the example project:
git clone https://github.com/dfinity/examples
cd examples/rust/who_am_iStart the local network and deploy:
icp network start -d
icp deployThe frontend is served by the asset canister. To run the Vite dev server with hot reload during frontend development:
npm run devWhen done, stop the local network to free the port and clear state:
icp network stopWhen 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.
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.didIf 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.