Quickstart

⚠️ Forking the workshop repo is a great starting point for your project to integrate Self. It contains a basic working example that demonstrates how to integrate Self. From this, you can add your own logic/requirements as needed.

Before You Start

New to Self Protocol? We highly recommend watching our ETHGlobal Buenos Aires Workshop first. This essential workshop walks through the core concepts and provides a hands-on introduction to building with Self.

Examples

Working examples of Self Protocol integration are available to use as a foundation to build upon.

Overview

To use Self in your web app, you will display QR codes to request proofs from your front-end, then you have a choice to verify them in your own back-end or onchain. All apps must integrate:

Frontend:

  • The front-end SDK generates and displays QR codes containing information from your app and what you want users to disclose.

Verification:

Installation

Install the required frontend packages:

Package purposes:

  • @selfxyz/qrcode: QR code generation and display components

  • @selfxyz/core: Core utilities including getUniversalLink for deeplinks

  • ethers: Ethereum utilities for address handling

Basic Usage

Here's a complete Next.js component example based on the workshop:

If you instead want to use the Self App on a mobile then we check out the Use deeplinking and Usage (Mobile) sections!

Verification Flow

The QR code component displays the current verification status with an LED indicator and changes its appearance based on the verification state:

  1. QR Code Display: Component shows QR code for users to scan

  2. User Scans: User scans with Self app and provides proof

  3. Verification:

    1. Onchain Verification: Your smart contract receives the proof and verifies it on the Self VerificationHub contract.

    2. Backend Verification: Your API endpoint receives and verifies the proof

  4. Success Callback: onSuccess callback is triggered when verification completes

Add SelfBackendVerifier to your backend

If you want to verify your proofs with the backend verifier, then you would implement the following.

Requirements

  • Node v16+

Install dependencies

Set Up SelfBackendVerifier

Key Points

Configuration Matching

Your frontend and backend configurations must match exactly:

Last updated