I'm trying to get merkle proof for Ethereum Smart Contract mapping field data. I created test smart contract and deployed to test network. Smart Contract Code like following code:

contract TestSmartContract {

mapping(string => string) mappingField;
address sender;

function TestSmartContract() public {
    sender = msg.sender;

function addData(string key,  string value) public {
    mappingField[key] = value;

I invoked smart contract addData method with test data.


After invoking smart contract, I tried to get value with web3 library, it works and i can get value for "a" key as "1".

var slot = "0".repeat(64);
            var key = web3.fromAscii('a');
            contractAddress = "0xac3f3d7286d8092be72d0011865a393ea722f609";
            var keccak256 = web3.sha3(key + slot, { encoding: 'hex' });
                function (err, result) {

As a final stage, I tried to create Merkle Proof for Key "a". I tried to use https://github.com/zmitton/eth-proof library for retrieving Merkle Proofs. But it gives "storageNode not found" error. You can find my test code below:

const Web3 = require('web3');
const EP = require('eth-proof')

var chainDataPath = '/Users/ramazan.girgin/chain-tmp/privchain/geth/chaindata/';
try {
    var latestBlockHash = 'f02052990b2ea9daa445c0a4655cb3a395a84c8300cba8258b8faf4357b109c7'
    Web3.providers.HttpProvider.prototype.sendAsync = Web3.providers.HttpProvider.prototype.send;
    var eP = new EP(
        new Web3.providers.HttpProvider(""),
    contractAddress = 'ac3f3d7286d8092be72d0011865a393ea722f609';
    eP.getStorageProof(contractAddress, '0','0x61').then((result) => {
    }).catch((e) => {
} catch (e) {

Actually, ZMitton uses https://github.com/ethereumjs/merkle-patricia-tree in this library. But i think there was a problem while sending path for storageTrie.findPath function in library getStorageProof method or i can incorrect values for getStorageProof() method. In the other hand, if i call getStorageProof for sender field , it gives complete proof.

eP.getStorageProof(contractAddress, '1').then((result) => {
        }).catch((e) => {

How can i retrieve merkle proof for mapping field in Smart Contract? Or how can i calculate correct path for storageTrie.findPath function parameter ?

Thanks in advance


bumped to the homepage by Community 2 hours ago

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


The https://github.com/zmitton/eth-proof is deprecated, you should use this new RPC calls https://github.com/ethereum/EIPs/issues/1186

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.