TestCredential
The TestCredential object abstracts most of the Block Qualified logic away, allowing you to easily interact with the protocol. It incorporates an OpenZeppelin Autotask for a transaction relayer, making it easier to onboard users.
Defining a TestCredential Object
You can define a new TestCredential object with the following syntax:
The value for openAnswersHashes
needs to be provided for tests that implement an open answers component, as defined for Block Qualified tests
To see the officially supported networks, check out the deployed contracts
Grading a Solution to a Test
Once initialized, you can use the TestCredential object to grade solutions to the test:
Where result
will be an object containing the following values:
grade
: over 100, grade obtained in the test.minimumGrade
: over 100, minimum grade needed to pass the test.pass
: whether the test was passed or not.nQuestions
: number of open answer questions that make up this test.multipleChoiceGrade
: grade obtained in the multiple choice component of this test.openAnswerGrade
: grade obtained in the open answer component of this test.multipleChoiceWeight
: percentage that the multiple choice component contributes towards the final grade.openAnswerResults
array containing boolean values indicating the result for each open answer question.
Generating and Verifying a Solution Proof
You can generate a test solution proof as described in Block Qualified Proofs by calling:
Where the value for identity
is a valid Semaphore identity that is then added to a given group, as described in the Block Qualified contracts.
The TestCredential object takes care of generating additional proofs when the credential being solved is restricted.
You can then verify this proof by calling:
Which will return true
or false
.
Sending a Solution Transaction
You can use the implemented OpenZeppelin Relayer to send this transaction free of gas.
This helps in increasing privacy, since all solving transactions get sent from the same relayer address.
Generating and Verifying a Rating Proof
You can generate a rating proof as described in Rating the Credential Issuer by calling:
Where the value for identity
is a valid Semaphore identity that must have already gained this test credential.
You can then verify this proof by calling:
Which will return true
or false
.
Sending a Rating Transaction
You can use the implemented OpenZeppelin Relayer to send this transaction free of gas.
This helps in increasing privacy, since all rating transactions get sent from the same relayer address.
Last updated