Ankr Verify
Integrating with Ankr Verify
Check User Compliance

Check if a user complied with a policy

Ankr Verify features a policy verification check-up. Calling the exist() function and providing it a policy ID, you can check if a specific policy has been successfully verified on the Ankr's side. In other words, if a user has successfully complied with a policy.

EVM-compatible

Smart Contracts

PolicyRegistry (opens in a new tab) (0xc492E85779BdCCEC18A099C6d8C2c9A3F74C94C5) — allows the user to check if a policy has been verified on the Ankr Verify's side.

Functions

exist(address user, uint256 id) returns (bool)

Checks if a specific policy has been successfully verified on the Ankr's side.

Parameters
  • user (address) — address of a vendor to check.
  • id (uint256) — policy ID.
Response

The function returns a boolean: true if the policy has been verified and false if not.

Example

As a read function, you can call exist() anytime and check the result.

Usage Example

contract DAPP {
   IPoliciesRegistry policyRegistry;
   uint256 policyId;
   bool isExecuted;

   modifier onlyVerified(){
       require(policyRegistry.exist(msg.sender, policyId), "DAPP: user is not verified");
       _;
   }

   function execute() external onlyVerified {
       isExecuted = true;
   }
}

SVM-compatible

Programs

PolicyRegistry (opens in a new tab) (4yrFxst43upUzQuJB8jJ2XH58FXQ3d9x98vuDAtEwC5Q) — allows the user to check if a policy has been verified on the Ankr Verify's side.

Functions

pub fn get_policy(ctx: Context<PolicyReturn>) -> Result<Policy>

Checks if a specific policy has been successfully verified on the Ankr's side.

Accounts
Input
PolictyReturn:
#[derive(Accounts)]
pub struct PolicyReturn<'info> {
   pub account: Account<'info, Policy>,
}

To derive the pub that is passed in the PolicyReturn account, you can rely on example:

To get policy verification you need to pass needed PDA inside the PolicyReturn struct. PDA can be derived from user pubkey and policy id.
Example:
[PDA] = anchor.web3.PublicKey.findProgramAddressSync(
   [
       user.toBuffer(),
       policy_id.toArrayLike(Buffer, "le", 8)
   ],
   policyRepo.programId
);
Output

The function returns:

Policy:
#[account]
pub struct Policy {
   pub cid: String,
   pub policy_id: u64,
   pub user: Pubkey,
}
Example

You can call the function anytime and check the result.

Usage Example

Refer to the example project we created for you. You may want to go to:

  • programs > integrationexample > src > lib.rs to find a program example.
  • tests > anchor.ts to find a frontend integration example.