This command enables to you install one of the available starters:
offchain: Sismo Connect +Next.js
request ZK Proofs from users and verify them in a backend
onchain: Sismo Connect +Next.js+Foundry+wagmi
request ZK Proofs from users and verify them in a smart contract
[Upcoming] onchain: Sismo Connect + Next.js + hardhat + ethers
coming very soon, until then, head over the Manual Installation if you want to use Sismo Connect with hardhat
Feel free to check the Sismo Connect Cheatsheet, a great companion when developing an app using Sismo Connect.
This section is intended for developers who have prior experience with incorporating new tools into their existing repositories.
Integrate Sismo Connect in Your Front End
Make a Sismo Connect Request, users will be redirected to their Data Vault to generate a ZK proof and send your front end a Sismo Connect Response.
This response, containing the ZK proof, will be verified on your back end/smart contract.
@sismo-core/sismo-connect-client is also available for non-React front ends. (docs)
Use our React Button to make Sismo Connect Requests
// Next.js https://nextjs.org/docs/getting-started/installation// in src/page.tsx "use client";import { SismoConnectButton, AuthType, SismoConnectResponse, ClaimType,} from"@sismo-core/sismo-connect-react";exportdefaultfunctionHome() {return (<SismoConnectButton config={{ appId:"0xf4977993e52606cfd67b7a1cde717069",// replace with your appId vault: {// For development purposes insert the Data Sources that you want to impersonate here// Never use this in production impersonate: [// EVM"leo21.sismo.eth","0xA4C94A6091545e40fc9c3E0982AEc8942E282F38","0x1b9424ed517f7700e7368e34a9743295a225d889","0x82fbed074f62386ed43bb816f748e8817bf46ff7","0xc281bd4db5bf94f02a8525dca954db3895685700",// Github"github:leo21",// Twitter"twitter:leo21_eth",// Telegram"telegram:leo21", ], },// displayRawResponse: true, }}// request proof of Data Sources ownership (e.g EVM, GitHub, twitter or telegram) auths={[{ authType:AuthType.GITHUB }]}// request zk proof that Data Source are part of a group// (e.g NFT ownership, Dao Participation, GitHub commits) claims={[// ENS DAO Voters { groupId:"0x85c7ee90829de70d0d51f52336ea4722" },// Gitcoin passport with at least a score of 15 { groupId:"0x1cde61966decb8600dfd0749bd371f12", value:15, claimType:ClaimType.GTE } ]} // request message signature from users. signature={{ message:"I vote Yes to Privacy" }}// retrieve the Sismo Connect Reponse from the user's Sismo data vault onResponse={async (response:SismoConnectResponse) => {const res =awaitfetch("/api/verify", { method:"POST", body:JSON.stringify(response), });console.log(awaitres.json()); }}// reponse in bytes to call a contract// onResponseBytes={async (response: string) => {// console.log(response);// }}/> );}
verify Sismo Connect responses sent from your front end
The Sismo Connect configuration and request used in your smart contract/backend must exactly match those from your frontend.
// in src/Airdrop.sol of a Foundry project - https://book.getfoundry.sh/getting-started/first-steps// SPDX-License-Identifier: MITpragmasolidity ^0.8.20;import"sismo-connect-solidity/SismoConnectLib.sol";// This is a sample contract that shows how to use the SismoConnect librarycontractAirdropisSismoConnect {eventResponseVerified(SismoConnectVerifiedResult result);constructor()SismoConnect(buildConfig({// replace with your appId from the Sismo factory https://factory.sismo.io/// should match the appId used to generate the response in your frontend appId:0xf4977993e52606cfd67b7a1cde717069,// For development purposes insert when using proofs that contains impersonation// Never use this in production isImpersonationMode:true }) ) {}functionverifySismoConnectResponse(bytesmemory response) public {// build the auth and claim requests that should match the response AuthRequest[] memory auths =new AuthRequest[](1); auths[0] =buildAuth({authType: AuthType.GITHUB}); ClaimRequest[] memory claims =new ClaimRequest[](2);// ENS DAO Voters claims[0] =buildClaim({groupId:0x85c7ee90829de70d0d51f52336ea4722});// Gitcoin passport with at least a score of 15 claims[1] =buildClaim({ groupId:0x1cde61966decb8600dfd0749bd371f12, value:15, claimType: ClaimType.GTE });// verify the response regarding our original request SismoConnectVerifiedResult memory result =verify({ responseBytes: response, auths: auths, claims: claims, signature:buildSignature({message:"I vote Yes to Privacy"}) });emitResponseVerified(result); }}
Create an API route to receive the Sismo Connect response and verify it.
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction// in src/app/api/verify/route.tsimport { AuthType, ClaimType, SismoConnect, SismoConnectVerifiedResult,} from"@sismo-core/sismo-connect-server";import { NextResponse } from"next/server";constsismoConnect=SismoConnect({ config: { appId:"0xf4977993e52606cfd67b7a1cde717069", vault: {// For development purposes insert the Data Sources that you want to impersonate here// Never use this in production impersonate: [// EVM"leo21.sismo.eth","0xa4c94a6091545e40fc9c3e0982aec8942e282f38",// Github"github:leo21",// Twitter"twitter:leo21_eth",// Telegram"telegram:leo21", ], }, },});// this is the API route that is called by the SismoConnectButtonexportasyncfunctionPOST(req:Request) {constsismoConnectResponse=awaitreq.json();try {// verify the sismo connect response that corresponds to the requestconstresult:SismoConnectVerifiedResult=awaitsismoConnect.verify(sismoConnectResponse, { auths: [{ authType:AuthType.GITHUB }], claims: [// ENS DAO Voters { groupId:"0x85c7ee90829de70d0d51f52336ea4722" },// Gitcoin passport with at least a score of 15 { groupId:"0x1cde61966decb8600dfd0749bd371f12", value:15, claimType:ClaimType.GTE }, ],// verify signature from users. signature: { message:"I vote Yes to Privacy" }, });returnNextResponse.json(result, { status:200 }); } catch (e:any) {console.error(e);returnNextResponse.json(e.message, { status:500 }); }}
If you are using Nextjs, you will need to add this config in the next.config.js file to be able to verify the proof. You can find more information here.