Contract Integration
Write the custom app contract that integrates with Brevis SDK.
The final step is to write a smart contract that handles the ZK-attested results. To streamline this process, you can use the contract SDK and implement the handleProofResult
function to process the circuit outputs.
Here is an example of a typical app contract:
Handling Circuit Outputs in Contract
Checking the Verifying Key
Reading the Circuit Output
Pay Request Fee
If an application is partnered with the Brevis system to serve requests with a customized fee plan, it can skip this step and send off-chain requests directly to the Brevis gateway.
Otherwise, for most applications, the user needs to send the request with fee in native tokens on-chain to the BrevisRequest
contract.
Paying the Fee
You need to call BrevisRequest.sendRequest
with the requestId
and the feeValue
(as transaction value) you acquire from in the previous step when you call app.PrepareRequest
in Go. The parameter _callback
is where you specify your app contract address.
Or, you can send a raw transaction using the calldata
you acquire from app.PrepareRequest
as the transaction call data and the feeValue
as the transaction value.
Refunding a Fee after Timeout
requestTimeout
a state variable in BrevisRequest
. If there is no proof submitted within the requestTimeout
, you can call BrevisRequest.refund
to refund the fee back to the _refundee
you initially specified when calling sendRequest
Last updated