Quadrata Integration
  • INTRODUCTION
    • Introduction to Quadrata
    • Passport Attributes
  • HOW TO INTEGRATE
    • Quadrata SDK
      • Get Started Quickly
      • Advanced
        • Installation
        • SDK Configuration
        • Onboarding Example
        • Client Libraries
          • Client Configuration
          • Client Lazy Loading
          • Client Eager Loading
          • Client Helper Component
          • Client React Hooks
            • useOnboardStatus
          • Client Examples
            • With Wagmi Connect
            • KYC Only
            • KYB Only
            • All In One
        • API Libraries
          • API Configuration
          • API Service Options
          • API Service Libraries
            • Create Access Token
            • Create Privacy Access Token
            • Fetch Attribute Values
            • Fetch Onboard Status
            • Fetch Passport List
            • Fetch Privacy Data
            • Fetch Privacy Grants
            • Fetch Wallet Screening
            • Revoke Privacy Grants
    • Onboard users
      • Individual Passport Onboarding
        • 1. Installation
        • 2. API Authentication
        • 3. API Onboard Status
        • 4. QuadClient Package
        • 5. Privacy Data Permissions
        • 6. Full Example
      • Business Passport Onboarding
        • 1. Installation
        • 2. API Authentication
        • 3. QuadrataKyb Package
        • 4. Privacy Data Permissions
        • 5. Full Example
      • All-In-One Passport Onboarding
        • 1. Installation
        • 2. API Authentication
        • 3. QuadrataReact Package
        • 4. Full Example
    • Request Privacy Data
      • List of Privacy Data
      • Privacy Data Permissions
      • API Requests
        • How to sign API
          • Full Example
          • Generate ECDSA Key Pair
        • API Get Privacy Permissions
        • API Privacy Access Token
        • API Get Privacy Data
        • API Revoke Permissions
    • Query attributes
      • Via Smart Contract
        • Query a single attribute
        • Query multiple attributes
        • Query Helper
      • Via API
    • On-Chain Wallet Screening
      • How to sign API
        • Full Example
        • Generate ECDSA Key Pair
      • API Get On-Chain AML Score
    • Webhooks
      • Onboarding Webhooks
      • Ongoing Monitoring Webhooks
      • Webhook Request Signature
    • Burn Passports
  • additional information
    • Smart contracts
    • Quadrata Sandbox
    • Passport Issuers
    • Privileged Roles & Ownership
    • Constants
    • Flex Kit Attributes
      • Smart Contract Addresses
Powered by GitBook
On this page
  • Requirements
  • Function
  • Example
  1. HOW TO INTEGRATE
  2. Query attributes
  3. Via Smart Contract

Query a single attribute

Use the getAttributes() function from the QuadReader smart contract to query a single attribute about a passport holder.

Requirements

Installation

Install @quadrata/contracts package

npm i @quadrata/contracts --save-dev

Permissions

Calling smart contract have to be granted permissions to call getAttributes in Mainnet. Contact us via email at contact@quadrata.com or Discord

Testnets like Goerli,Mumbai,etc.. do not require any permissions

Function

QuadReader.sol
import "@quadrata/contracts/interfaces/IQuadPassportStore.sol";

// For Solidity version >= 0.8.0.
reader.getAttributes(
    address user, 
    bytes32 attribute
) external payable returns(
    IQuadPassportStore.Attribute[] memory attributes
);


// For Solidity version < 0.8.0.
reader.getAttributesLegacy(
    address user, 
    bytes32 attribute
) external payable returns(
    bytes32[] attributeValues, 
    uint256[] epochs, 
    address[] issuers
);

Parameters

Parameter
Description
Type

user

address of the passport holder

address (required)

attribute

bytes32 (required)

Return values

A list of attributes that have been issued.

IQuadPassportStore.sol
/// @dev Attribute store infomation as it relates to a single attribute
/// `attrKeys` Array of keys defined by (wallet address/DID + data Type)
/// `value` Attribute value
/// `epoch` timestamp when the attribute has been verified by an Issuer
/// `issuer` address of the issuer issuing the attribute
struct Attribute {
    bytes32 value;
    uint256 epoch;
    address issuer;
}

For Solidity version < 0.8.0

UsegetAttributesLegacy()which returns three arrays. The index of each array maps to the others to create a tuple (e.g. attributeValues[0], epochs[0], issuers[0] are part of the same result).

  • attributeValues: Raw or hashed attribute values. See Supported attributes for the return values of each attribute.

  • epochs: Timestamp that indicates when the attribute was verified by the passport issuer.

  • issuers: Passport issuer who verified the attributes.

Example

You can find our helper library to facilitate parsing the response => QuadReaderUtils

import "@quadrata/contracts/interfaces/IQuadReader.sol";
import "@quadrata/contracts/interfaces/IQuadPassportStore.sol";
import "@quadrata/contracts/utility/QuadReaderUtils.sol";

contract MyDapp {
    using QuadReaderUtils for bytes32;
    IQuadReader public reader;
    
    function borrowMoney() external payable {
        IQuadPassportStore.Attribute[] memory attributes = reader.getAttributes(
            msg.sender, 
            keccak256("COUNTRY")
        );

        require(attributes.length > 0, "REQUIRES_COUNTRY");
        
        // only users residing outside the US may borrow money        
        if (!attributes[0].value.countryIsEqual("US")) {
            // Allow borrow actions
        }
    }

PreviousVia Smart ContractNextQuery multiple attributes

Last updated 1 year ago

The attribute you want to query. See: .

Supported attributes