Skip to content

Instantly share code, notes, and snippets.

@blakewest
Last active April 26, 2021 14:56
Show Gist options
  • Save blakewest/8e90d72dbee24376a3afc7787091fc1e to your computer and use it in GitHub Desktop.
Save blakewest/8e90d72dbee24376a3afc7787091fc1e to your computer and use it in GitHub Desktop.
Solidity Blogpost #1: Config Contract, snippet 3
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