Haven1
  • Get started
    • 🧑‍🚀Welcome Havenauts!
    • 📄Haven1 Litepaper
    • 🧮H1 Tokenomics
  • Foundations of Haven1
    • 📐Architecture & network design
    • 🔐Network-level security
    • 📚Haven1 Core protocols
    • 💱Best in class liquidity
    • 👮Network Guardians: Firewall on Haven1
    • 🌉hBridge: Intro to Haven1 Bridge
  • Learn
    • 💵What does Haven1 solve?
    • 💡Haven1: Use Cases
    • 📚Understanding GoQuorum
    • 🔤Haven1 Blockchain basics
    • 🛂KYC policies on Haven1 blockchain
    • Security at Haven1
    • 🔓What is esH1?
    • ⚖️Dispute resolution mechanism
    • 🛣️Haven1 Roadmap
    • 🖥️Haven1 is EVM compatible
  • Products
    • 🔃hSwap - Spot DEX on Haven1
    • 📍hsETH on Haven1
    • Earn on Haven1
    • 🛡️2FA Wallet Shield
    • 🧊Haven1 block explorer
    • 🏛️Governance & veH1
    • 🆔hPassport - Key to Haven1
      • Advantages of having ID verification at a network level
      • Understanding the ID Verification Process
    • 💼Vesting esH1 - Converting esH1 to H1
    • 📍Staking H1 & esH1 - Earning rewards on your H1 holdings
      • Flexible Staking
      • Locked Staking
  • hPerpetuals - Perps DEX on Haven1
  • Haven1 Guides
    • 🔗Quick links
    • ✅Haven1 onboarding Guide
      • 🪪KYC Guide
      • Business KYC(KYB) Guide
    • Adding multiple wallets to a hPassport
    • 🌉Simple Bridging Guide on Haven1 network
    • 🏠Haven1 Portal - Your Gateway into Haven1
    • 🔑2FA Set up Guide
    • 🤑Haven1 Airdrop: Claim Process and Strategies
    • Claim Process Walkthrough on Team Finance
    • 📄Contract Addresses
  • Build
    • 📖Getting started
    • 🌐Haven1 Network information
    • 🍦Novel developer benefits on Haven1
    • 📑High level guide for secure deployment
    • ⚙️Detailed deployment Guide
    • 🧰Developer tools
      • 👛Haven1 Gnosis Safe wallet
      • 🛠️Haven1 SDK
        • 🔌@haven1/sdk-api-client
          • Class: Haven1SDK
          • Class: AuthModule
          • Class: SdkModule
        • ⛓️@haven1/blockchain-sdk
          • Contracts
        • 🧰@haven1/wagmi-sdk
          • Constant Module
            • Variable: haven1Devnet
            • Variable: haven1Testnet
            • Variable: H1
          • Contract Module
            • ProofOfIdentity
            • ProofOfIdentityV2
            • NativeAppFee
          • Utility Module
            • bigIntMax
            • formatBigint
            • bigintFromDecimals
          • Hook Module
            • useWatch
            • useBalance
            • useApproveERC20
            • useContractWrite
        • ⚛️@haven1/react-sdk
          • useHaven1SDK
          • useAuth
          • useIdentity
          • useNotifications
          • useOTP
          • useSignIn
        • 📜Use cases & Examples
          • Adding the Notification Component to Your React UI
          • Check Proof of Identity (POI) Status
      • Oracles on Haven1
      • Subgraph on Haven1
      • Haven1 block explorer
      • Web3 libraries and tools
    • Development frameworks
    • 🔐Using hPassport in Your dApps
      • Integrating hPassport into Your dApp
      • Implementing Identity Checks in Smart Contracts
        • Country codes
      • Sample Application - Country ID
      • Sample Application - Composable verification level
      • Sample Application - User type
      • Repository Information
    • ⛽Application fees
      • FeeContract.sol
      • Example FeeContract Interactions
      • Case Studies
    • 👷Builders grants program
  • Additional resources
    • 📚Haven1 terminology
  • Quick Links
    • Website
    • Twitter
    • Blog
    • Telegram
    • Customer Support
Powered by GitBook
On this page
  • Example Code
  • Usage
  • Example Code using ProofOfIdentity wagmi wrap Contract hook
  • Usage
  • Contract Addresses
  1. Build
  2. Developer tools
  3. Haven1 SDK
  4. Use cases & Examples

Check Proof of Identity (POI) Status

This guide provides an example of how to check if a user is POI active by verifying that the user's ProofOfIdentity balance is more than 0 and that the user is not suspended.

Example Code

import { ProofOfIdentityContract as ProofOfIdentityContractSDK } from '@haven1/blockchain-sdk/contract';
import { useReadContracts } from 'wagmi';
import { Address } from 'viem';

type CheckPOIStatusParameters = {
  address: Address;
  contractAddress: Address;
  chainId: number;
};

export const checkPOIStatus = async ({
  address,
  contractAddress,
  chainId,
}: CheckPOIStatusParameters) => {
  const { data: poiResult, isLoading, isError } = useReadContracts({
    contracts: [
      {
        address: contractAddress,
        chainId,
        abi: ProofOfIdentityContractSDK.abi,
        functionName: 'balanceOf',
        args: [address],
      },
      {
        address: contractAddress,
        chainId,
        abi: ProofOfIdentityContractSDK.abi,
        functionName: 'isSuspended',
        args: [address],
      },
    ],
  });

  if (isLoading) {
    console.log('Loading POI status...');
    return;
  }

  if (isError) {
    console.error('Error fetching POI status');
    return;
  }

  const balance = poiResult?.[0]?.result;
  const isSuspended = poiResult?.[1]?.result;

  if (balance > 0 && !isSuspended) {
    console.log('User is POI active');
  } else {
    console.log('User is not POI active');
  }
};

Usage

const params = {
  address: '0xUserAddress',
  contractAddress: '0xContractAddress',
  chainId: Haven1Testnet,
};

checkPOIStatus(params);

This example demonstrates how to use the checkPOIStatus function to verify if a user is POI active by checking their balance and suspension status.

Example Code using ProofOfIdentity wagmi wrap Contract hook

import { ProofOfIdentity } from '@haven1/wagmi-sdk/contract';
import { useEffect } from 'react';

const CheckPOIStatusWithHook = ({ address, contractAddress, chainId }) => {
  const { data, isLoading, isError } = ProofOfIdentity({
    address,
    contractAddress,
    chainId,
  });

  useEffect(() => {
    if (isLoading) {
      console.log('Loading POI status...');
      return;
    }

    if (isError) {
      console.error('Error fetching POI status');
      return;
    }

    const { balance, isSuspended } = data;

    if (balance > 0 && !isSuspended) {
      console.log('User is POI active');
    } else {
      console.log('User is not POI active');
    }
  }, [data, isLoading, isError]);

  return null;
};

Usage

const params = {
  address: '0xUserAddress',
  contractAddress: '0xContractAddress',
  chainId: Haven1Testnet,
};

<CheckPOIStatusWithHook {...params} />;

This example demonstrates how to use the useProofOfIdentity hook to verify if a user is POI active by checking their balance and suspension status.

Contract Addresses

Here are the contract addresses for different environments:

Proof of identity V1

  • devnet: 0xd635521BA9c5694a2237EA94f2455aBfdDF41ef9

  • testnet: 0xDb5ecc06e7C82d3ed4dBA699b8E8D0433A3ED729

Proof of identity V2

  • devnet: 0x89B63B0698b03B01F7b75f0e1973DE6270D89dA5

  • testnet: N/A

PreviousAdding the Notification Component to Your React UINextOracles on Haven1

Last updated 1 month ago

🧰
🛠️
📜