Usage
This example will help you get started with a basic backend implementation to start proof requests and verify proofs.
Step-by-Step Implementation
1. Install the SDK
Make sure you have installed the SDKs by following the instructions on the Installation page.
2. Prepare your variables
- You will need to have the
APPLICATION_ID
andAPPLICATION_SECRET
from dev.reclaimprotocol.org. - You will also need to add providers to your application, keep the
PROVIDER_ID
handy too. - The providers you add to the application, will be the providers you will be able to ask the user to generate a proof for.
- Make sure you add to your Application from the dev tool.
3. Create the Proof Request generator endpoint
This endpoint defines what proof you are requesting from the user.
If you are deploying this on localhost, be sure to use ngrok to make your server accessible over the internet.
Create a new file named server.js
and add the following code:
Do not use the express.urlencoded()
middleware as it will conflict with the express.text()
middleware above. The proof object sent to the callback URL needs to be parsed as text, otherwise it won't be processed correctly.
4. Add the Receive Proof endpoint to verify the proofs
This endpoint will be called once the user generates the proof. Here is where we must verify the submitted proof and execute business logic accordingly.
Add this function to your server.js
If not using a middleware to parse the body, be sure to parse the body manually, like so:
For detailed information about the proof
object received in the /receive-proofs
endpoint, refer to the Proof Structure section.
3. Run the server
Start your Express server:
4. Display the Proof Request to the user
You can now display the Proof Request to the user, by following the Fullstack Example here