Sismo Docs
  • Welcome to Sismo
    • What is Sismo?
  • Build with Sismo Connect
    • Overview
    • Installation
    • Sismo Connect Cheatsheet
    • Tutorials
      • Get Your appId - Create a Sismo Connect App
      • Onchain Tutorial (1/2): Code Your Airdrop Contract With Privately-Aggregated Data
      • Onchain Tutorial (2/2): Deploy Your Airdrop Contract
    • Technical Documentation
      • Sismo Connect Configuration
      • Auths
      • Claims
      • Signature
      • Packages
        • Sismo Connect Client: Request
        • Sismo Connect React: Request
        • Sismo Connect Server: Verify Offchain
        • Sismo Connect Solidity Library: Verify Onchain
    • FAQ
  • Data Groups
    • Overview
    • Tutorials
      • Factory Guide: Create a Data Group in 5 Minutes
      • Sismo Hub Guide: Create Data Groups Programmatically
      • Sismo Hub Guide: Add a Data Provider to the Sismo Factory
    • Sismo Hub
      • Sismo Hub Repository
        • Group Generators
        • Data Providers
        • Data Operators
        • Command Line Interface
      • Accounts Registry Tree
  • Data Vault
    • Overview
    • Vault Identifiers
    • Proving Schemes
      • Hydra-S1
      • Hydra-S2
    • Commitment Mapper
  • Resources
    • Deployed Contract Addresses
    • Sismo API
      • API Links
      • Query From a Client
      • Group
        • Get groups
        • Get group snapshots
      • Common Parameters
      • Advanced Filtering
      • Transaction
  • Links
    • Sismo Landing Page
    • Sismo Factory
    • Sismo App Store
    • Sismo Builder Resources
    • GitHub
    • Discord
    • Twitter
    • Blog
Powered by GitBook
On this page
  • Installation
  • Example Usage
  • getResponse()
  1. Build with Sismo Connect
  2. Technical Documentation
  3. Packages

Sismo Connect Client: Request

Request proofs from your user

PreviousPackagesNextSismo Connect React: Request

Last updated 1 year ago

The Sismo Connect Client is a front-end package built on top of the app (the prover) to easily request proofs from your users with , and .

Installation

Install the Sismo Connect Client package in your front end with npm or yarn:

# with npm
npm install @sismo-core/sismo-connect-client
# with yarn
yarn add @sismo-core/sismo-connect-client

Make sure to have at least v18.15.0 as Node version. You can encounter issues with ethers dependencies if not.

Example Usage

Here is an example of a customized usage of the request function:

You want to create an NFT airdrop for holders of a Nouns DAO NFT owning a Gitcoin Passport and a Twitter account.

So you want your users to prove that they own a Nouns DAO NFT. In order to make your airdrop more Sybil-resistant, you will require them to also prove a Gitcoin Passport ownership with a passport value greater or equal to 15 and a Twitter account ownership.

These proofs should be made for the service named "sismo-edition". When the proofs are generated, you want your users to be redirected to the claim page of your website at the path "https://my-nft-drop.xyz/sismo-edition/claim-nft".

You will then use these proofs to airdrop an NFT if they are valid.

import { 
  AuthRequest, 
  AuthType, 
  ClaimRequest, 
  ClaimType,
  SismoConnect,
  SismoConnectConfig
} from "@sismo-core/sismo-connect-client";

const config: SismoConnectConfig = {
  // you will need to get an appId from the Factory
  appId: "0xf4977993e52606cfd67b7a1cde717069", 
}

const sismoConnect = SismoConnect({
  config
})

// auth request for a proof of Twitter account ownership
const twitterRequest: AuthRequest = { 
    authType: AuthType.TWITTER,
};

// claim request for a proof of "Nouns DAO Nft holders" group membership
const nounsDaoRequest: ClaimRequest = { 
    // id of the group nouns-dao-nft-holders
    // https://factory.sismo.io/groups-explorer?search=nouns-dao-nft-holders
    groupId: "0x311ece950f9ec55757eb95f3182ae5e2",
};

// claim request for a proof of "Gitcoin Passport holders" group membership
const gitcoinPassportRequest: ClaimRequest = { 
    // id of the group gitcoin-passport-holders
    // https://factory.sismo.io/groups-explorer?search=gitcoin-passport-holders
    groupId: "0x1cde61966decb8600dfd0749bd371f12",
    // users should have at least 15 as value in the group to claim the airdrop
    value: 15,
    claimType: GTE
};

// redirect users to the Vault App to generate proofs based on the requirements
// expressed in the auth and claim requests
sismoConnect.request({
    auth: twitterRequest,
    claims: [nounsDaoRequest, gitcoinPassportRequest],
    namespace: "sismo-edition",
    callbackUrl: "https://my-nft-drop.xyz/sismo-edition/claim-nft"
})

getResponse()

function getResponse(): SismoConnectResponse | null

getResponseBytes()

function getResponseBytes(): string | null

SismoConnectResponse

type SismoConnectResponse = {
    // the appId registered in the Factory
    appId: string;
    // Sismo Connect version
    version: string;
    // service from which the proof is requested
    namespace?: string;
    signedMessage?: string;
    proofs: SismoConnectProof[]
}

type SismoConnectProof = {
    auths?: Auth[];
    claims?: Claim[];
    provingScheme: string;
    proofData: string;
    extraData: any;
}

A namespace is useful when you want your users to generate proofs for different services in an app. You can see more information about how to use it in the .

The getResponse function returns the object containing the proofs generated by your user after coming back from the Data Vault app. Proofs can be sent to your back end and verified thanks to the package OR sent to your contract that uses the to verify.

The getResponseBytes function returns the response encoded in bytes usable by the Library.

Sismo Connect Server package documentation
@sismo-core/sismo-connect-solidity
@sismo-core/sismo-connect-server
Sismo Connect Solidity library
SismoConnectResponse
AuthRequests
ClaimRequests
SignatureRequests
Data Vault