-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: UsingWitnetRandomness abstract contract
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity >=0.7.0 <0.9.0; | ||
pragma experimental ABIEncoderV2; | ||
|
||
import "../WitnetRandomness.sol"; | ||
|
||
/// @title The UsingWitnetRandomness contract | ||
/// @dev Contracts willing to interact with WitnetRandomness appliance should just inherit from this contract. | ||
/// @author The Witnet Foundation. | ||
abstract contract UsingWitnetRandomness | ||
is | ||
IWitnetOracleEvents, | ||
IWitnetRandomnessEvents | ||
{ | ||
WitnetOracle immutable public witnet; | ||
WitnetRandomness immutable public _RNG; | ||
|
||
constructor(WitnetRandomness _witnetRandomness) { | ||
require( | ||
address(_witnetRandomness).code.length > 0 | ||
&& _witnetRandomness.specs() == type(WitnetRandomness).interfaceId, | ||
"UsingWitnetRandomness: uncompliant WitnetRandomness appliance" | ||
); | ||
_RNG = _witnetRandomness; | ||
witnet = _RNG.witnet(); | ||
} | ||
|
||
} | ||
|