Tutorial

How to build a Brevis app that proves a token transfer

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, TWAP, etc. You can also check out this helpful video tutorial on building a trading volume-based fee discount feature in Uniswap v4.

The example in this tutorial only supports pure ZK mode. Please follow this previous section to support coChain mode

The App: Proving Token Transfer

Our app's goal is to allow anyone to prove to our on-chain contract that an Ethereum address has made a USDC token transfer whose amount is more than 500 USDC.

We will implement this app step by step. The finished version is also available in this repo.

How can an ERC-20 Transfer be proven?

When an ERC-20 token transfer is made, a Transfer event will be emitted in the transaction receipt. By reading this log, we can find From in topics and Value in data.

In the tutorial application, we are going to write an Brevis app checking that the value more than is 500000000 (500 with decimal 6) for a transaction receipt.

Contents

Building the App CircuitWriting the App ContractPutting Everything Together

Last updated