-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
78 additions
and
17 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
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 |
---|---|---|
@@ -1,14 +1,23 @@ | ||
# Drand Oracle | ||
# 🎲 Drand Oracle | ||
|
||
A Solidity smart contract and updater service for bringing randomness from the [drand network](https://drand.love) on-chain. | ||
|
||
## Overview | ||
## 📄 Contract | ||
|
||
This project consists of two main components: | ||
The `DrandOracle` smart contract serves as an on-chain source of randomness by storing values from the drand network. | ||
|
||
1. A Solidity smart contract (`DrandOracle.sol`) that stores randomness values along with necessary metadatas and signatures to verify the randomness off chain. | ||
2. A Go updater service that fetches new randomness from drand and updates the contract. | ||
For more information, see the [contract README](contracts/README.md). | ||
|
||
## Contract | ||
## 🔄 Updater | ||
|
||
The randomness stored in the contract is verifiable off-chain but not on-chain. This is due to BLS signatures used by Drand network are not yet supported on EVM. | ||
The updater service fetches new randomness from drand and updates the `DrandOracle` contract with its managed signer and sender EOA addresses. | ||
|
||
For more information, see the [updater README](updater/README.md). | ||
|
||
## 📝 License | ||
|
||
This project is licensed under the [MIT License](LICENSE). | ||
|
||
## 🤝 Contributing | ||
|
||
Contributions are welcome! Please feel free to open an issue or submit a Pull Request. |
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,62 @@ | ||
# 📄 Drand Oracle Smart Contract | ||
|
||
## 🔎 Overview | ||
|
||
The `DrandOracle` smart contract serves as an on-chain source of randomness by storing values from the drand network. | ||
|
||
## 📚 Core Contracts | ||
|
||
### 🎲 DrandOracle.sol | ||
|
||
The main contract responsible for storing and managing randomness from the drand network. | ||
|
||
#### 🛠️ Usage | ||
|
||
- `getRandomnessFromRound(uint64 _round) external view returns (Random memory)` | ||
- Retrieves the complete randomness data for a specific round | ||
- Parameters: | ||
- `_round`: The round number to query | ||
- Returns: | ||
- `Random memory`: The Random struct containing the round's data | ||
- `getRandomnessFromTimestamp(uint64 _timestamp) external view returns (Random memory)` | ||
- Retrieves the complete randomness data for a specific timestamp, or the latest timestamp prior to the given timestamp if no exact match is found | ||
- Parameters: | ||
- `_timestamp`: The timestamp to query | ||
- Returns: | ||
- `Random memory`: The Random struct containing the timestamp's data | ||
|
||
### 🔒 Access Control | ||
|
||
The contract implements a simple single-updater access control pattern: | ||
|
||
- Only the designated updater address can submit new randomness | ||
- Updater address is set during contract deployment | ||
- Updater can be updated by the owner | ||
|
||
### ⚠️ Limitations | ||
|
||
1. The randomness stored in the contract is verifiable off-chain but not on-chain. This is due to BLS signatures used by Drand network are not yet supported on EVM. | ||
2. Reliance on trusted updater. | ||
|
||
### 🧪 Testing | ||
|
||
Run tests with: | ||
|
||
```bash | ||
forge test | ||
``` | ||
|
||
### 💻 Run Locally | ||
|
||
1. Start local anvil chain | ||
|
||
```bash | ||
anvil | ||
``` | ||
|
||
2. Deploy the contract | ||
|
||
```bash | ||
forge build | ||
make deploy-anvil | ||
``` |
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