> For the complete documentation index, see [llms.txt](https://docs.quadrata.com/integration/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.quadrata.com/integration/how-to-integrate/query-attributes/via-smart-contract/query-helper.md).

# Query Helper

Quadrata provides a suite of helper functions as a library contract deployed on chain.

{% hint style="info" %}
The library implementation is available on our [github](https://github.com/QuadrataNetwork/passport-contracts/blob/develop/contracts/utility/QuadReaderUtils.sol).&#x20;
{% endhint %}

### Installation

[QuadReaderUtils.sol](https://github.com/QuadrataNetwork/passport-contracts/blob/develop/contracts/utility/QuadReaderUtils.sol) can be imported from Quadrata [contract npm package](https://www.npmjs.com/package/@quadrata/contracts) starting from v0.3.1.

```shell
npm i @quadrata/contracts --save-dev
```

## AML

{% hint style="info" %}
Description: Anti-money laundering risk scoring of the passport holder.
{% endhint %}

### amlIsEqual(bytes32 \_attrValue, uint256 \_expectedAmlValue)

Checks if returned AML attribute value is equal to supplied uint256 value.

```solidity
import "@quadrata/contracts/utility/QuadReaderUtils.sol";

using QuadReaderUtils as bytes32;

IQuadPassportStore.Attribute[] memory attributes = reader.getAttributes{
    value: queryFee
}(_account, keccak256("AML"));

if (attributes[0].value.amlIsEqual(8))
    // Checks if _account has an AML risk score equals to 8
```

### amlGreaterThan(bytes32 \_attrValue, uint256 \_lowerBound)

Checks if returned AML attribute value is greater than supplied uint256 value.

### amlGreaterThanEqual(bytes32 \_attrValue, uint256 \_lowerBound)

Checks if returned AML attribute value is greater than or equal to supplied uint256 value.

### amlLessThan(bytes32 \_attrValue, uint256 \_upperBound)

Checks if returned AML attribute value is less than supplied uint256 value.

### amlLessThanEqual(bytes32 \_attrValue, uint256 \_upperBound)

Checks if returned AML attribute value is less than or equal to supplied uint256 value.

### amlBetweenInclusive(bytes32 \_attrValue, uint256 \_lowerBound, uint256 \_upperBound)

Checks if returned AML attribute value is between a min and max threshold inclusively.

```solidity
import "@quadrata/contracts/utility/QuadReaderUtils.sol";

using QuadReaderUtils as bytes32;

IQuadPassportStore.Attribute[] memory attributes = reader.getAttributes{
    value: queryFee
}(_account, keccak256("AML"));

if (attributes[0].value.amlBetweenInclusive(2, 8))
    // Checks if _account has an AML risk score between 2 and 8
```

### amlBetweenExclusive(bytes32 \_attrValue, uint256 \_lowerBound, uint256 \_upperBound)

Checks if returned AML attribute value is between a min and max threshold exclusively.

```solidity
import "@quadrata/contracts/utility/QuadReaderUtils.sol";

using QuadReaderUtils as bytes32;

IQuadPassportStore.Attribute[] memory attributes = reader.getAttributes{
    value: queryFee
}(_account, keccak256("AML"));

if (attributes[0].value.amlBetweenExclusive(2, 8))
    // Checks if _account has an AML risk score between 2 (excluded) and 8 (excluded)
```

## IS\_BUSINESS

{% hint style="info" %}
Defines whether the passport is for an individual consumer or a business entity.
{% endhint %}

### isBusinessTrue(bytes32 \_attrValue)

Checks if returned isBusiness attribute value is True.

```solidity
import "@quadrata/contracts/utility/QuadReaderUtils.sol";

using QuadReaderUtils as bytes32;

IQuadPassportStore.Attribute[] memory attributes = reader.getAttributes{
    value: queryFee
}(_account, keccak256("IS_BUSINESS"));

if (attributes[0].value.isBusinessTrue())
    // address _account is a Business Passport
```

## COUNTRY

{% hint style="info" %}
Defines the country where the government ID was issued. Uses ISO 31266 standard for two-letter country encodings.&#x20;
{% endhint %}

### countryIsEqual(bytes32 \_attrValue, string \_expectedCountry)

Checks if returned country attribute value is equal to supplied string value.

```solidity
import "@quadrata/contracts/utility/QuadReaderUtils.sol";

using QuadReaderUtils as bytes32;

IQuadPassportStore.Attribute[] memory attributes = reader.getAttributes{
    value: queryFee
}(_account, keccak256("COUNTRY"));

if (attributes[0].value.countryIsEqual("US"))
    // address _account is not equal to "US"
```

##

## CRED\_PROTOCOL\_SCORE

{% hint style="info" %}
Cred Protocol’s credit score predicts the likelihood of borrowers being liquidated or defaulting on loans in the next 90 days (range 300-1000)

\
Visit <https://www.credprotocol.com/> for more information
{% endhint %}

### credProtocolScoreIsEqual(bytes32 \_attrValue, uint256 \_expectedScore)

Checks if returned Cred Protocol Score attribute value is equal to supplied uint256 value.

```solidity
import "@quadrata/contracts/utility/QuadReaderUtils.sol";

using QuadReaderUtils as bytes32;

IQuadPassportStore.Attribute[] memory attributes = reader.getAttributes{
    value: queryFee
}(_account, keccak256("CRED_PROTOCOL_SCORE"));

if (attributes[0].value.credProtocolScoreIsEqual(750))
    // Checks if Cred Protocol Score is equal to "750"
```

### credProtocolScoreGreaterThan(bytes32 \_attrValue, uint256 \_lowerBound)

Checks if returned Cred Protocol Score attribute value is greater than supplied uint256 value.

### credProtocolScoreGreaterThanEqual(bytes32 \_attrValue, uint256 \_lowerBound)

Checks if returned Cred Protocol Score attribute value is greater than or equal to supplied uint256 value.

### credProtocolScoreLessThan(bytes32 \_attrValue, uint256 \_upperBound)

Checks if returned Cred Protocol Score attribute value is less than supplied uint256 value.

### credProtocolScoreLessThanEqual(bytes32 \_attrValue, uint256 \_upperBound)

Checks if returned Cred Protocol Score attribute value is less than or equal to supplied uint256 value.

### credProtocolScoreBetweenInclusive(bytes32 \_attrValue, uint256 \_lowerBound, uint256 \_upperBound)

Checks if returned Cred Protocol Score attribute value is between a min and max threshold inclusively.

### credProtocolScoreBetweenExclusive(bytes32 \_attrValue, uint256 \_lowerBound, uint256 \_upperBound)

Checks if returned Cred Protocol Score attribute value is between a min and max threshold exclusively.
