This project demonstrates how to generate a proof using Reclaim's zkFetch and verify it on-chain using ethers.js. It fetches the Ethereum price from the CoinGecko API, generates a proof for the fetched data, and then verifies the proof on a smart contract deployed on the blockchain.
- Node.js and npm installed
- Access to a blockchain RPC URL (e.g., Base Sepolia network)
- A Reclaim app ID and app secret from Reclaim Dashboard
- Address of a deployed Reclaim contract you can find how to deploy your own or use our already deployed contract from our Documentaion
-
Clone the Repository
git clone https://gitlab.reclaimprotocol.org/starterpacks/zkfetch-ethers-example.git cd zkfetch-ethers-example -
Install Dependencies
npm install
-
Create a
.envFile:Create a .env file in the root directory and populate it with the content mentioned in the
.env.exampleMake sure to replace the placeholders with your actual values. -
Running the Script To execute the proof verification script, run:
node index.js
The script will:
- Fetch the Ethereum price from the CoinGecko API (As an Example).
- Generate a proof for the fetched data.
- Verify the proof on-chain using the provided contract address.
index.js: The main script for generating and verifying proofs.contractABI.json: The ABI for the smart contract with the verifyProof function..env: Environment variables for configuring the script (You need to create it with the help of.env.example).
- Make sure your wallet has enough funds to pay for gas fees on the specified network.
- The script uses the Base Sepolia test network by default. You can change the
RPC_URLandCONTRACT_ADDRESSto point to your preferred network and contract.