✨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.
logoReclaim Protocol Docs

Local Development

Running an attestor locally

Reclaim's attestor is a stateless machine, you can start generating proofs with your local setup, all you need is a private key for your attestor.

Overview

Following this doc, you will be able to run an attestor locally and start generating Reclaim proofs.

Flows

Running the attestor

The workflow is as follows:

  1. Clone the attestor-core repository:
    • git clone https://github.com/reclaimprotocol/attestor-core.git
  2. Install packages:
    • npm i
  3. Create an .env.producation with at least the PRIVATE_KEY variable populated:
    • PRIVATE_KEY=0x...
  4. Start the server:
    • NODE_ENV=production npm run start --env-file=.env.production -- src/scripts/start-server

Running the last command will print a WebSocket url for you, you will need this in the next step.

Generating a proof

Now that your attestor is running in the background, you can connect to it and start generating proofs:

  1. Create a node.js environment:

    • npm init --yes
  2. Install attestor-core:

    • npm i https://github.com/reclaimprotocol/attestor-core
  3. Download ZK files:

    • node node_modules/@reclaimprotocol/zk-symmetric-crypto/lib/scripts/download-files
  4. Create a .js file with the following script and plug in your attestor's metadata:

const { createClaimOnAttestor } = require("@reclaimprotocol/attestor-core");
 
const claimObj = 
{
// change the claim obj (with the provider data)
 method: "GET",
 url: "https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd",
 responseMatches: [
 {
   type: "regex",
   value: '{"ethereum":{"usd":(?<usd>.*?)}}',
 },
 ],
 responseRedactions: [
 {
   regex: '{"ethereum":{"usd":(?<usd>.*?)}}',
 },
 ],
 geoLocation: "",
 body: "",
 paramValues: {},
 headers: {},
};
 
const createClaim = async () => 
{
try {
 const claim = await createClaimOnAttestor({
 name: "http",
 params: 
 {
   method: claimObj.method,
   url: claimObj.url,
   responseMatches: claimObj.responseMatches,
   responseRedactions: claimObj.responseRedactions,
   geoLocation: claimObj.geoLocation,
   body: claimObj.body,
   paramValues: claimObj.paramValues,
   additionalClientOptions: {},
 },
 secretParams:
 {
   headers: claimObj.headers,
   cookieStr: "",
   authorisationHeader: "",
 },
 ownerPrivateKey: "", // Replace with your private key
 client:
 {
   url: "", // Replace with your attestor's host url
 },
});
 
console.log(claim);
 
} catch (error) {
console.log(error);
}
};
 
createClaim();

Deploying Your Own Reclaim Server

Deploying a Reclaim server is straightforward using the docker-compose. The server is stateless, allowing for easy horizontal scaling. Follow these steps after running docker compose up:

  1. Set up a proxy: Use a reverse proxy, such as Nginx, to make the Reclaim HTTP server accessible over the internet.
  2. Configure HTTPS: Implement HTTPS on your reverse proxy.
  3. Configure WebSocket: Configure your reverse proxy to handle WebSocket connections, which are essential for Reclaim's functionality.

You should then have an RPC URL in the format wss://<your-domain>/ws. To confirm your server is working correctly on mobile devices through a browser-based RPC, navigate to https://<your-domain>/browser-rpc. If the server is correctly configured, you will see the message "Attestor Core RPC".

On this page