Retrieving data
Once defined, the bqTest object loads all the necessary information into memory, which can be accessed via the methods described below.
For this section we will make use of the testnet deployed contracts to provide implementation examples. First, we will define a new bqTest object in reading mode by doing:
Where, for this example, ethersProvider is a valid ethers.providers.JsonRpcProvider for the Mumbai testnet, since this is were the testing smart contracts are located. An exam has already been created on TestCreator.sol, with testId = 1.
The bqSDK allows us to easily retrieve data about this defined test:
stats: returns the stats for this test, that is, the Test struct for this test. This attribute will return the entire Test struct:
But we can also choose to query its individual keys:
The meaning of each of these keys is given inside the definition of the Test struct
isValid: returns whether this test is currently solvable or not. A test is valid immediately after being minted, and can only be invalidated by the owner, which is a permanent action.
URI: returns the test URI.
holdersNumber: returns the number of holders for this credential, that is, the amount of people who have solved the test.
async holdersList(): returns the list of the accounts that have received this credential.
async holdsCredential(address): returns whether the specified address has received this credential.
Note that you may not get exactly the same values as provided here as other users solve this demo test.
Last updated