This repo contains a simple end-to-end brevis application that proves the account age for a given user and handles the attested age in an app contract.
- Go >= 1.20
- Node.js LTS
The prover service is a standalone process that is run on a server, preferably as a systemd managed process so that it can be auto restarted if any crash happens. The prover service is designed to be used in conjunction with brevis-network/brevis-sdk-typescript.
cd prover
make start
You may want to have a process daemon to manage the prover services in production. The Makefile in the project root contains some convenience scripts.
To build, init systemd, and start both prover processes, run the following command. Note it requires sudo privilege because we want to use systemd commands
cd prover
make deploy
The Node.js project in ./app is a simple program that does the following things:
- call the Go prover with some transaction data to generate an account age proof
- call Brevis backend service and submit the account age proof
- wait until the final proof is submitted on-chain and our contract is called
cd app
npm run start [TransactionHash]
Example
npm run start 0x6dc75e61220cc775aafa17796c20e49ac08030020fce710e3e546aa4e003454c
The app contract AccountAge.sol is called after you submit proof is submitted to Brevis when Brevis' systems submit the final proof on-chain. It does the following things when handling the callback:
- checks the proof was associated with the correct vk hash
- decodes the circuit output
- emit a simple event
cd contracts
npm install
npm run test
Rename .env.template
to .env
. Fill in the required env vars.
npx hardhat deploy --network sepolia --tags AccountAge