Im new to solidity and trying to figure out if there is any way to retrieve a mappings key value for example from the transaction data in which you set it?

mapping (uint => bool) private solution;

function setSolution(uint _number){
    solution[_number] = true;}

Would it be possible for anyone to find the current value of _number in any way while or after I have set it, or is it hidden?


If solution is private then it is available only within the contract.

private: Private functions and state variables are only visible for the contract they are defined in and not in derived contracts.

Solidity Docs # visibility


Be careful of the answers being given here!

In context of solidity you may not be able to access private mapping from outside the contract BUT

Everything in Ethereum blockchain is PUBLIC

Nodes store copies of entire blockchain and if someone wants they can read your data if its not encrypted. Be sure to write encrypted data if you want true privacy.

Ref 1: Private Info on Ethereum

Ref 2: Storing private data on the ethereum blockchain

  • This is exactly the point of my question, to find out if its posible to read out the data in any way. And if yes, how? – Xinorl Jul 16 '18 at 9:24

The answer is simple: you can NOT from any other smart contract. BUT you can without problem using forensic analysis, i.e. “downloading” all or “the relevant” portion of the blockchain and inspecting it with proper tools.

I.e. “private” does not mean “secret” at all, but means “accessible with specific effort only”.

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.