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
  1. Build
  2. Using hPassport in Your dApps

Implementing Identity Checks in Smart Contracts

Step-by-step guide on integrating identity verification in smart contracts.

  1. Contract Setup: Start by defining the OPERATOR_ROLE in your contract, which is crucial for managing permissions within your smart contract. Ensure that your contract correctly initializes and interacts with the Proof of Identity contract.

  2. Issuing Identity with issueIdentity:

    • Understand and implement the issueIdentity function. This is a critical function for creating a Proof of Identity NFT for verified users.

    • Parameters like primaryID, countryCode, userType, and expiries need to be correctly set based on the userโ€™s verified information.

    • The uri parameter can link to additional information about the user, stored off-chain for privacy.

  3. Attribute Management:

    • Utilize attribute-related functions such as setStringAttribute and setBoolAttribute to assign specific characteristics to a user's profile.

    • These attributes could range from basic personal information to more complex data relevant to your application, like accreditation status or membership details.

Implementing Identity Verification in Smart Contracts

  1. Fetching and Validating Token IDs:

    • Leverage tokenID(address account) to retrieve the token ID linked to a user's identity. This ID is fundamental for verifying if a user has undergone the necessary identity checks.

    • Implement logic to handle scenarios where a token ID might not exist or be invalid.

  2. Utilizing Identity Attributes in Contract Logic:

    • Country Code Validation: Employ getCountryCode for geo-specific logic, such as restricting or allowing transactions based on the user's location.

    • User Competency: Integrate getCompetencyRating to evaluate if a user meets certain skill or competency criteria, essential in specialized applications.

    • User Type Differentiation: Use getUserType to categorize users into different groups like retail or institutional, and modify the contract's behavior accordingly.

  3. Integrating Attribute-Based Access Control:

    • Design your smart contract functions to check for specific attributes before allowing transaction execution. This ensures that only qualified or authorized users can perform certain actions within your contract.

    • Use events like AttributeSet and IdentityIssued to keep track of changes in user attributes and identities.

Advanced Contract Features

  1. Handling Token URI Updates:

    • Implement the setTokenURI function to update the metadata or information linked to a userโ€™s Proof of Identity NFT.

    • This allows for dynamic updates to a user's profile or identity information while maintaining the integrity of the NFT.

  2. Custom Attribute Integration:

    • Go beyond the standard attributes and implement custom attributes relevant to your application. This could include user preferences, historical transaction data, or other relevant information.

    • Use functions like setU256Attribute or setBytesAttribute for custom data types.

  3. Error Handling and Security:

    • Ensure your contract properly handles potential errors such as ProofOfIdentity__InvalidAttribute or ProofOfIdentity__AlreadyVerified.

    • Implement security measures to protect against unauthorized access or manipulation of user identity information.

PreviousIntegrating hPassport into Your dAppNextCountry codes

Last updated 10 months ago

๐Ÿ”