Integration Guide

Allow your users to sign in using their DIDChain Identity. Instead of passwords, users authenticate using their digital wallet, providing you with a verified Web3 Identity and a Reputation Score directly from the blockchain.

1Prerequisites

Before using DIDChain, you and your users need a digital wallet and tokens to interact with the Sepolia blockchain.

A. Create a Wallet

Download MetaMask, the industry-standard wallet, as a browser extension.

Download MetaMask →

B. Get Sepolia ETH

You need free "Testnet ETH" to pay for blockchain gas fees. Use a faucet to get some.

Get Free ETH →

Note: Make sure to switch your MetaMask network to Sepolia Test Network.

2Identity Registration

To use "Sign-In with DIDChain", your users must first have a registered identity on our platform.

  1. Visit the DIDChain Dashboard.
  2. Fill in the profile form (Name, Email, Institution).
  3. Click "Register on Blockchain" and approve the MetaMask transaction.
  4. Wait for confirmation. Once registered, your user now has a DID and a Trust Score!

After registration, the user is now ready to sign in to any third-party app integrated with DIDChain.

3Add the Button

Include our professional CSS and the authorization link in your login page.

<!-- Include Styles -->
<link rel="stylesheet" href="https://did-blockchain.onrender.com/css/did-button.css">

<!-- Sign In Button -->
<a href="https://did-blockchain.onrender.com/authorize?redirect_uri=YOUR_URL" class="did-connect-button">
  <span class="did-icon">⬡</span>
  Sign in with DIDChain
</a>
LIVE PREVIEW ⬡ Sign in with DIDChain

4Handle the Callback

After the user approves the signature, we redirect them back to your redirect_uri with a token.

https://your-site.com/callback?did_token=JWT_TOKEN_HERE&address=0x...

Extract the did_token from the URL query parameters to verify it in the next step.

5Verify the Token (Backend)

Crucial Security Step: After receiving the token on the frontend, you must never trust it immediately. Your backend should send the token to our verification endpoint to ensure it was actually signed by DIDChain and hasn't been tampered with.

const response = await fetch('https://did-blockchain.onrender.com/verify-token', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ token: 'JWT_TOKEN_HERE' })
});

const result = await response.json();
if (result.valid) {
  // result.data contains address and score
  console.log("Verified User:", result.data.sub);
  console.log("Trust Score:", result.data.score);
}

API Reference

Endpoint Type Description
/verify-token POST Verifies a JWT token issued by DIDChain.
/score/:address GET Returns the trust score for a specific public address.
/identity/:cid GET Fetches user meta-data from IPFS via CID.