Last active
March 24, 2020 14:42
-
-
Save alexroan/3cc693c6b15524a0e1061929495b060b to your computer and use it in GitHub Desktop.
examples/solidity-mappings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity >=0.5.0; | |
contract Mappings { | |
// State variable | |
mapping(address => uint) public myMapping; | |
// Store a new value in the mapping | |
function putThing(address _key, uint _value) public { | |
myMapping[_key] = _value; | |
} | |
// Retrieve a value from the mapping using key to search | |
function getThing(address _search) public view returns (uint){ | |
return myMapping[_search]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment