✨Works out of the box guarantee. If you face any issue at all, hit us up on Telegram and we will write the integration for you.

Solidity
Quickstart

Quickstart for Solidity

Pre-requisite

This tutorial assumes that you have a frontend that requests proofs from the user and processes the response, like React, React Native, or Node.

Supported Networks

Before diving into the Solidity integration, ensure you are aware of the supported networks where Reclaim contracts are already deployed. The Reclaim Solidity SDK supports a variety of EVM-compatible chains, including Ethereum, Polygon, Arbitrum, BNB Chain, and more.

For a full list of supported networks and their contract addresses, check out the supported networks here.

Solidity

This section walks you through deploying and integrating a Reclaim contract into your Solidity project.

Deploy a smart contract

Deploy the following contract to any EVM-compatible network of your choice. In this walkthrough, we'll be using Ethereum as an example.

// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
 
import "@reclaimprotocol/verifier-solidity-sdk/contracts/Reclaim.sol";
import "@reclaimprotocol/verifier-solidity-sdk/contracts/Addresses.sol";
 
contract Attestor {
   address public reclaimAddress;
 
   constructor() {
      // Replace with the network you are deploying on
      reclaimAddress = Addresses.ETHEREUM;
   }
 
   function verifyProof(Reclaim.Proof memory proof) public view {
       Reclaim(reclaimAddress).verifyProof(proof);
       // Your business logic upon successful verification
       // Example: Verify that proof.context matches your expectations
   }
}

You can check out the supported networks by the @reclaimprotocol/verifier-solidity-sdk package in here (opens in a new tab)

Context Field

Each proof contains a context field inside the proof.claimInfo structure. This field allows you to embed additional data, such as a message and an address, which can be useful for verifying specific context details like user identity or specific claims (e.g., SteamId if you're using the SteamId provider).

Since context is a string, you may want to extract specific fields from it. To simplify this, the Reclaim SDK provides the following utility function:

function extractFieldFromContext(string memory data, string memory target)
public pure returns (string memory)
  • data: The context string from the proof.
  • target: The name of the field you wish to extract.

Example

To extract the SteamId from the context, pass the target in this format:

'"SteamId":"'
⚠️

Ensure the target string is formatted exactly as shown, including the double quotes and colon. format: '"FIELD_NAME_HERE":"' (e.g. '"SteamId":"')

You can use the same function to extract other context fields such as contextAddress or contextMessage using the same approach.

Obtain Artifacts

After deploying the contract, make sure to take note of the following essential details:

  • Chain ID: For example, ETHEREUM has a chain ID of 1.
  • Contract Address: The address of your deployed contract.
  • ABI: The contract's Application Binary Interface, which you will need for interacting with the contract.

Publish on chain

You can publish your contract and interact with it using popular libraries like:

  • wagmi.js – A set of React hooks for Ethereum development.
  • ethers.js – A comprehensive library for interacting with the Ethereum blockchain.