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';typeCheckPOIStatusParameters= { address:Address; contractAddress:Address; chainId:number;};exportconstcheckPOIStatus=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; }constbalance= poiResult?.[0]?.result;constisSuspended= poiResult?.[1]?.result;if (balance >0&&!isSuspended) {console.log('User is POI active'); } else {console.log('User is not POI active'); }};