Last active
April 26, 2021 14:56
-
-
Save blakewest/8e90d72dbee24376a3afc7787091fc1e to your computer and use it in GitHub Desktop.
Solidity Blogpost #1: Config Contract, snippet 3
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
contract GoldfinchConfig is Ownable { | |
// Note: Solidity creates automatic getter methods for these mappings | |
// So we don't need to explicitly add them ourselves. | |
mapping(uint256 => address) public addresses; | |
mapping(uint256 => uint256) public numbers; | |
event AddressUpdated(address owner, uint256 index, address oldValue, address newValue); | |
event NumberUpdated(address owner, uint256 index, uint256 oldValue, uint256 newValue); | |
function setAddress(uint256 addressIndex, address newAddress) public onlyAdmin { | |
emit AddressUpdated(msg.sender, addressIndex, addresses[addressIndex], newAddress); | |
addresses[addressIndex] = newAddress; | |
} | |
function setNumber(uint256 index, uint256 newNumber) public onlyAdmin { | |
emit NumberUpdated(msg.sender, index, numbers[index], newNumber); | |
numbers[index] = newNumber; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment