Skip to main content

Sign in with Solana

Advanced
Solana

Overview

The ic-siws (SIWS) project provides ICP dapps with a way to enable Solana-based authentication. The project's goal is to enhance the interoperability between ICP and Solana by enabling developers to build dapps that can use both chains.

The ic-siwe (SIWE) project is also available for enabling Ethereum-based authentication.

You can try the deployed demo here: https://guidq-3qaaa-aaaal-qiteq-cai.icp0.io

Key features

  • Solana Wallet Sign-In: Enables any Solana wallet to generate an ICP identity and sign into ICP dapps.

  • Prebuilt identity solution: Provides a prebuilt canister that can be integrated into any ICP project, independent of the project's programming language.

  • Direct Solana wallet address to Principal mapping: Uses a 1:1 correlation between Solana addresses and Principals.

  • Consistent principal generation: Ensures each Solana wallet produces the same Principal.

  • Session identity uniqueness: Verifies that each session identity is specific to each application's context.

  • Timebound sessions: Developers can set expiration times for sessions to enhance control and security.

Usage

To use SIWS, developers have two possible workflows:

  1. Use the prebuilt ic_siws_provider**: The pre-built identity provider canister can be integrated with any ICP project by adding the canister's information to the project's dfx.json file. When using the pre-built canister solution, the following login workflow is used:
  • An ICP dapp requests a SIWS message on behalf of a user from the ic_siws_provider canister.

  • The dapp displays the SIWS message to the user who must sign it with their Solana wallet.

  • The dapp sends the signed SIWS message to the ic_siws_provider canister. The canister verifies the signature and creates an ICP Principal for the user.

  • The dapp retrieves the Principal from the ic_siws_provider canister and can now use the new Principal to make authenticated calls for the user.

  1. Use the ic_siws Rust library directly: Provides developers with full control over the SIWS integration through the ic_swis library.

Resources