I have a centralized e-commerce system with orders table inside. There are few order categories inside this system such as:

  • Pending payment
  • Pending shipping
  • Pending delivery
  • Completed
  • Cancelled

I want to store all orders in a Merkle tree for accountability sake (maybe once a day).

If I put all orders under all categories above in one same tree, does it possible to perform Merkle root proof with filter as required argument?

For example, does it possible to proof order ID 1 under category Completed is part of the Merkle tree?

What I'm expecting is something like this:

  • If supplied category is Completed, it should return true
  • If supplied category is not Completed, it should return false

I read about Merkle tree, Merkle proofs and sparse Merkle tree. But I'm still clueless. I welcome all ideas from members here. Implementation wise, I can code Solidity, Golang and Node. The verification app can be in Golang or Node.

  • it's totally possible. You can hash the whole tree and perform all kind of queries. example of your leaf: ` bytes32 _leaf = keccak256(abi.encodePacked(keccak256(abi.encode(_category, _id)))); ` – rstormsf Sep 26 '19 at 6:40
  • checkout merkle tree here: multisender.app (PULL strategy) feel free to use Kovan testnet – rstormsf Sep 26 '19 at 6:43
  • 1
    @rstormsf - thank you for the input. I'm curious, why we need two keccak256 here? Thanks. – Zulhilmi Zainudin Sep 26 '19 at 16:32
  • you don't have to have 2 keccack256, feel free to make a different leaf structure. – rstormsf Sep 29 '19 at 16:44
  • 1
    @rstormsf thank you. – Zulhilmi Zainudin Sep 30 '19 at 3:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.