Last active
April 15, 2022 17:41
-
-
Save critesjosh/6249eaa78597cefe6bd89aeb6c74f5e6 to your computer and use it in GitHub Desktop.
Example solidity contract that uses the randomness contract
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
| import "celo-monorepo/packages/protocol/identity/interfaces/IRandom.sol"; | |
| import "celo-monorepo/packages/protocol/common/interfaces/IRegistry.sol"; | |
| contract Example { | |
| function test() external view returns (bytes32 randomness) { | |
| randomness = IRandom( | |
| IRegistry(0x000000000000000000000000000000000000ce10) | |
| .getAddressFor(keccak256(abi.encodePacked("Random"))) | |
| ).random(); | |
| } | |
| } |
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
| import "celo-monorepo/packages/protocol/common/UsingRegistryV2.sol"; | |
| contract Example is UsingRegistryV2 { | |
| function test() external view returns (bytes32 randomness) { | |
| randomness = getRandom().random(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment