I am beginner in mapping.I work on Truffle and Ganache. I deploy the following contract:

pragma solidity ^0.5.12;
contract customerFinder{
    mapping(uint256 => address payable) public addressStorage;

    function filling(uint256 iden, address payable sender) public{

    function finder(uint256 id) public view returns(address payable){
       return addressStorage[id];

Ganache shows the storage of the contract:

enter image description here

After that, i run the filling() function by truffle:

enter image description here

And a new block created. But, i expect the contract's storage be changed and no change occurrs.

enter image description here

Is there any problem or my expectation is false?

  • It says next to the mapping "not supported yet". It seems ganache UI has not implemented a way to inspect mappings, but they work in the smart contract. – Ismael Feb 27 at 4:05
  • What truffle version are you running? – DRP Feb 28 at 15:12
  • Truffle version 5.1.8 – Alireza Mar 1 at 13:13

I tried your filling function, and it works perfectly on my side.

However, as your mapping is public, you can access it in the same way that I'm using your finder function.

On my side everything is ok, maybe Ganache is not displaying this output correctly, but I tried on Remix, and I'm able to retrieve the corresponding mapped address.

| improve this answer | |

The mapping structure saves its index data as hash, not plain data. So no external party can see its values, even if you mention the mapping variable as public.

So the only way you can its values is to use a function such finder in your code.

| improve this answer | |

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.