Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

104
Views
MerkProof.Verify Always Retuns false on solidity but returns true frontend

I have this code for verifying a merkleproof on solidity

event beforeClaim(bytes32 root, bytes32 node,  bool proof);

    function claim(
        address account,
        uint256 amount,
        bytes32[] calldata merkleProof
    ) public {
        require(claimed[account] == false, 'user already claimed');

        bytes32 node = keccak256(abi.encodePacked(account, amount));

        emit beforeClaim(merkleRoot, node, MerkleProof.verify(merkleProof, merkleRoot, node));

And this code on the frontend

export interface User {
    address: string;
    amount: string;
}

function getElements(users: User[]) {
    const elements = users.map((x) => {
        return utils.solidityKeccak256(['address', 'uint256'], [x.address, parseFloat(x.amount)])
    }
    );
    return elements;
}

export function getProof(users: User[], userAddress: string): string[] {
    const index = users.findIndex((user) => user.address === userAddress);
    const elements = getElements(users);
    const leaf = elements[index];
    const merkleTree = new MerkleTree(elements, keccak256, { sort: true });
    const proof = merkleTree.getHexProof(leaf);
    return proof;
}

The root, node, merkleproof values match both on solidity and frontend but on the frontend the result is true and somehow the MerkleProof.verify() returns false always regardless of the values matching both on frontend and solidity (I passed the values manually but still the result from solidity is false)

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!