Blockchain Merkle Proof Verification Smart Contract

Job ID: 38773481

Budget: ₹600 – ₹1,500 INR

Merkle Proof Verification of Blockchain Transactions
Overview
You are building a smart contract that can verify the presence of a specific transaction from a given block on a blockchain (Sepolia or zkSync) using Merkle proofs. This task will involve constructing a Merkle tree from block transactions, storing the Merkle root in the contract, and enabling users to verify individual transactions by submitting Merkle proofs.

Steps
Fetch Transactions from a Block
Using a web3 provider, retrieve all transactions from a specific block number (e.g., block #some_number).
Use the Sepolia or zkSync testnet to collect transaction data.
Generate a Merkle Tree and Proof
Construct a Merkle tree from the transaction hashes within the block.
Select one transaction hash and generate a Merkle proof that shows its inclusion in the Merkle tree.
Deploy a Smart Contract for Merkle Verification
Develop a smart contract with the following functionality:
Merkle Root Storage: The contract should store the Merkle root of the transactions from the specified block.
Merkle Proof Verification: Implement a function to verify the inclusion of a transaction hash using a Merkle proof and the stored Merkle root.
Smart Contract Functionality
Set Merkle Root: This function, callable only by the contract owner, stores the Merkle root corresponding to a block's transactions.
Verify Transaction Inclusion: This function accepts a transaction hash and its Merkle proof as inputs and verifies whether the transaction is part of the stored Merkle tree. It returns true if the proof is valid and false otherwise.
Testing
Frontend Interface:
Develop a simple React interface to interact with the contract.
Allow users to input a transaction hash and Merkle proof to verify inclusion on-chain.
Display the verification result.
Additional Considerations for Testing
Gas Optimization: Measure gas usage for the Merkle proof verification function.
Access Control: Test that only the owner can set the Merkle root.
Edge Cases: Verify behavior with empty or malformed proofs and check that the contract responds as expected when handling invalid Merkle trees.