Sismo Connect Client: Request

Request proofs from your user

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

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"
})

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 Sismo Connect Server package documentation.

getResponse()

function getResponse(): SismoConnectResponse | null

The getResponse function returns the SismoConnectResponse 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 @sismo-core/sismo-connect-server package OR sent to your contract that uses the Sismo Connect Solidity library to verify.

getResponseBytes()

function getResponseBytes(): string | null

The getResponseBytes function returns the response encoded in bytes usable by the @sismo-core/sismo-connect-solidity Library.

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;
}

Last updated