Tutorial

How to build a Brevis app that proves an account's age.

This tutorial will walk you through an minimal example for the aforementioned workflow of developing a Brevis app. Check out this repo for some more advanced examples, such as trading volume proof on Uniswap.

The App: Proving an Account's Age

Our app's goal is to allow anyone to prove to our on-chain contract that the age of an Ethereum account is older than block X. If a user wants to attest their age, we generate a proof for them and then our contract will emit an event showing the user's age has been attested.

We are going to implement this app step by step. You can also find the finished version in this repo.

How an Account's Age Can be Proven

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 a 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.

Contents

pageBuilding the App CircuitpageWriting the App ContractpagePutting Everything Together

Last updated