Skip to content

How to verify tries in Solidity? #1096

@alvin854

Description

@alvin854

I'm looking to generate a Merkle tree in JS and verify proofs on-chain in Solidity. There are Solidity libraries like OpenZeppelin's MerkleProof.sol that let me do so, but I can't find a reliable Merkle library in JS. merkle-patricia-trees seems to be the most reliable, but I can't find any examples on how I would verify tries in Solidity.

With a Merkle tree, each of my objects would look something like this:

{
    address: "0x123",
    token: "0x456",
    amount: "15000000000000000000"
}

...which I would ideally hash with something like web3.utils.soliditySha3(address, token, amount), and pass an array of those leaves to the tree.

Am I correct in thinking that in a trie, the key would be Buffer.from(address) and the value would be Buffer.from('${token}${amount}')? And then how would I verify that in Solidity? Would really appreciate a hand or any resources that I may have overlooked. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions