Tutorial
How to build a Brevis app that proves an account's age.
Last updated
How to build a Brevis app that proves an account's age.
Last updated
This tutorial will walk you through a minimal example of the aforementioned workflow for developing a Brevis app. Check out this repo for some more advanced examples, such as trading volume proof on Uniswap. You can also check out this helpful video tutorial on building a trading volume-based fee discount in Uniswap v4.
The example in this tutorial only supports pure ZK mode. Please follow this previous section to support coChain mode
Our app's goal is to allow anyone to prove to our on-chain contract that an Ethereum account's age is older than block X. If a user wants to attest their age, we generate proof for them, and then our contract will emit an event showing the user's age has been attested.
We will implement this app step by step. The finished version is also available in this repo.
We define an account's "birthday" as "the time an address's private key is known to someone". Anyone can prove this by showing that there exists a valid transaction of nonce 0 such that it is signed correctly by that "someone" and the transaction has reached the blockchain consensus.
In our tutorial application, we are going to write an application circuit that checks that the nonce is 0 for a transaction. When we submit our proof to Brevis, it then checks that the transaction is included in a valid block.