This repo contains the server code you'll need to set up a VC (Verifiable Credential) gated website with Polygon ID. Complete local server setup below, then hook this verification server up to a frontend so you can limit access based on holding a VC that satisifies your requirements.
-
Allows Socket.io polling to emit session specific events back to connected clients
-
Generates a Query Based Request in the form of a QR code that the user can scan to prove they own a credential that satisfies certain requirements. It also specifies the callback endpoint for verification
-
Reports Verification of the proof sent by the user from their Polygon ID Wallet via callback
cd server
npm i
In your .env file,
cp .env.sample .env;
- Update the
RPC_URL_MUMBAI
to a Polygon Mumbai RPC endpoint. I used Alchemy's - Optionally update the
VERIFIER_DID
to your DID - Don't change
HOSTED_SERVER_URL
orFRONTEND_URL
yet
npm start
If you don't have ngrok already set up, install ngrok via homebrew or download. Login (I used github login) to create a free account and add your account's config token to the command line.
After ngrok is set up, start a tunnel to port 8080 to expose your server to the internet beyond only being available to your laptop on localhost:8080. This is necessary because the Polygon ID mobile wallet app will use a verfication uri you provide and needs to be able to send the verification result to this exposed public endpoint.
ngrok http 8080
You'll see a forwarding address in the logs
Forwarding https://abc-your-forwarding-address-def.ngrok-free.app -> http://localhost:8080
HOSTED_SERVER_URL="https://abc-your-forwarding-address-def.ngrok-free.app"
You are currently running the server on localhost and forwarding to ngrok to exposse it to the internet.
If you'd like to host the server, you can use something like Render, Connect your repo, then make sure to add all your environment variables from .env. Update the HOSTED_SERVER_URL environment variable to match the server domain created by Render.