Check if a user has a passport

Check if the wallet holder has a Quadrata Passport for a specific attribute by calling the function balanceOf

Function

QuadPassport.sol
function balanceOf(walletAddress: string, attributeType: string): Promise<number>
Note: The Quadrata Passport is a non-transferrable NFT.

Parameters

Parameter
Description
Type
walletAddress
Wallet address.
string (required)
attributeType
The attribute type. See list of all available attributes
string (required)

Return values

Number of attributes available for a Passport Holders

Example

The following example uses ethers.js to interact with a QuadReader smart contract.
React.js
Vue.js
Angular.js
import { ethers } from "ethers";
import { id } from 'ethers/lib/utils';
import QUAD_READER_ABI from "./abis/QuadReader.json";
const checkAvailablePassportAttribute = async (attributeType: string) => {
// Wraps a standard Web3Provider, which is
// what MetaMask injects as window.ethereum into each page
const provider = new ethers.providers.Web3Provider(window.ethereum);
await provider.send("eth_requestAccounts", []);
// The QuadReader address
const readerContractAddress = "0xFEB98861425C6d2819c0d0Ee70E45AbcF71b43Da";
// Retrieve the connected wallet
const signer = provider.getSigner();
const walletAddress = await signer.getAddress();
// The QuadReader Contract object
const readerContract = new ethers.Contract(
readerContractAddress,
QUAD_READER_ABI,
provider
);
// Checking if a wallet owns a passport with attributes being issued
readerContract.balanceOf(walletAddress, attributeType).then((balance) => {
// balance returned is a BigNumber object, checking if it's greater than zero.
if (balance.isZero()) {
// address does not own a passport with this attribute.
} else {
// address has a Quadrata Passport with attributes being attested to.
}
});
};
// Check if the connected wallet has the "AML" attribute attested in the Passport
// If not, the user should be prompt to claim their Quadrata Passport
checkAvailablePassportAttribute(id("AML"));
Coming soon.
Coming soon.