Skip to content

Instantly share code, notes, and snippets.

@alexroan
Last active March 24, 2020 14:42
Show Gist options
  • Save alexroan/3cc693c6b15524a0e1061929495b060b to your computer and use it in GitHub Desktop.
Save alexroan/3cc693c6b15524a0e1061929495b060b to your computer and use it in GitHub Desktop.
examples/solidity-mappings
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