Integrating hPassport into Your hApp
Sample smart contract interactions for provable identity applications on Haven1.
1. Retrieve User Attributes from hPassport
solidityCopy code// Retrieve the userโs primary identity
(bool primaryID, uint256 expiry, uint256 updatedAt) = proofOfIdentity.getPrimaryID(userAddress);
// Ensure the user is verified
require(primaryID, "User is not verified.");solidityCopy code// Retrieve the userโs country code
(string memory countryCode, uint256 expiry, uint256 updatedAt) = proofOfIdentity.getCountryCode(userAddress);2. Enforcing Identity Verification in Smart Contracts
solidityCopy codepragma solidity ^0.8.0;
import { IProofOfIdentity } from "./IProofOfIdentity.sol";
contract VerifiedAuction {
IProofOfIdentity proofOfIdentity;
constructor(address _proofOfIdentity) {
proofOfIdentity = IProofOfIdentity(_proofOfIdentity);
}
modifier onlyVerified(address user) {
(bool primaryID,,) = proofOfIdentity.getPrimaryID(user);
require(primaryID, "User is not verified.");
_;
}
function placeBid() external onlyVerified(msg.sender) {
// auction logic here
}
}3. Personalizing User Experiences Based on hPassport Attributes
4. Handling Suspended Users
5. Multiple Account Support
hPassport API Reference
Identity Verification Functions
Auxiliary Account Functions
Example Use Case: Auction with Verified Users
Important Notes
Identity Verification Checks
Testing
Last updated