You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> When prompted to choose a Solidity framework, you can pick either **Hardhat** or **Foundry**. Both are fully supported. The screenshots in this guide may show one or the other, but the concepts are identical.
67
+
59
68
> 💻 In the same terminal, start your local network (a blockchain emulator in your computer):
60
69
61
70
```sh
@@ -98,8 +107,19 @@ yarn start
98
107
99
108
### 🔗 Simple Oracle - The Building Block
100
109
110
+
<Tabs>
111
+
<Tablabel="Hardhat">
112
+
101
113
🔍 Open the `packages/hardhat/contracts/00_Whitelist/SimpleOracle.sol` file to examine the basic oracle functionality.
102
114
115
+
</Tab>
116
+
<Tablabel="Foundry">
117
+
118
+
🔍 Open the `packages/foundry/contracts/00_Whitelist/SimpleOracle.sol` file to examine the basic oracle functionality.
119
+
120
+
</Tab>
121
+
</Tabs>
122
+
103
123
#### 📖 Understanding the Code:
104
124
105
125
🧩 The `SimpleOracle` contract is the fundamental building block of this oracle system:
@@ -128,8 +148,19 @@ yarn start
128
148
129
149
🎯 **Your Mission**: Complete the missing function implementations in the `WhitelistOracle.sol` contract.
130
150
151
+
<Tabs>
152
+
<Tablabel="Hardhat">
153
+
131
154
🔍 Open the `packages/hardhat/contracts/00_Whitelist/WhitelistOracle.sol` file to implement the whitelist oracle functionality.
132
155
156
+
</Tab>
157
+
<Tablabel="Foundry">
158
+
159
+
🔍 Open the `packages/foundry/contracts/00_Whitelist/WhitelistOracle.sol` file to implement the whitelist oracle functionality.
160
+
161
+
</Tab>
162
+
</Tabs>
163
+
133
164
#### 📖 Understanding the Relationship:
134
165
135
166
The `WhitelistOracle` contract **creates and manages multiple SimpleOracle contracts**:
@@ -335,7 +366,7 @@ function getActiveOracleNodes() public view returns (address[] memory) {
335
366
336
367
for (uint256 i = 0; i < oracles.length; i++) {
337
368
(, uint256 timestamp) = oracles[i].getPrice();
338
-
if (timestamp > block.timestamp - STALE_DATA_WINDOW) {
369
+
if (block.timestamp - timestamp < STALE_DATA_WINDOW) {
🔍 Run the following command to check if you implemented the functions correctly.
432
463
433
-
```sh
464
+
<Tabs>
465
+
<Tablabel="Hardhat">
434
466
435
-
yarn test --grep "Checkpoint1"
467
+
**Hardhat**
436
468
469
+
```shell
470
+
yarn test --grep "Checkpoint1"
437
471
```
438
472
439
473
✅ Did the tests pass? You can dig into any errors by viewing the tests at `packages/hardhat/test/WhitelistOracle.ts`.
440
474
475
+
</Tab>
476
+
<Tablabel="Foundry">
477
+
478
+
**Foundry**
479
+
480
+
```shell
481
+
yarn test --match-test "Checkpoint1"
482
+
```
483
+
484
+
✅ Did the tests pass? You can dig into any errors by viewing the tests at `packages/foundry/test/WhitelistOracle.t.sol`.
485
+
486
+
</Tab>
487
+
</Tabs>
488
+
441
489
### Try it out!
442
490
443
491
🔄 Run `yarn deploy --reset` then test the whitelist oracle. Try adding and removing oracles, and observing how the aggregated price changes.
@@ -486,8 +534,19 @@ yarn simulate:whitelist
486
534
487
535
🎯 **Your Mission**: Complete the missing function implementations in the `StakingOracle.sol` contract. The contract skeleton is already provided with all the necessary structs, events, and modifiers but you need to fill in the logic.
488
536
537
+
<Tabs>
538
+
<Tablabel="Hardhat">
539
+
489
540
🔍 Open the `packages/hardhat/contracts/01_Staking/StakingOracle.sol` file to implement the staking oracle functionality.
490
541
542
+
</Tab>
543
+
<Tablabel="Foundry">
544
+
545
+
🔍 Open the `packages/foundry/contracts/01_Staking/StakingOracle.sol` file to implement the staking oracle functionality.
546
+
547
+
</Tab>
548
+
</Tabs>
549
+
491
550
### ✏️ Tasks:
492
551
493
552
1.**Implement `getCurrentBucketNumber()`**
@@ -1179,14 +1238,31 @@ function exitNode(uint256 index) public onlyNode {
1179
1238
1180
1239
🔍 Run the following command to check if you implemented the functions correctly.
1181
1240
1182
-
```sh
1241
+
<Tabs>
1242
+
<Tablabel="Hardhat">
1183
1243
1184
-
yarn test --grep "Checkpoint2"
1244
+
**Hardhat**
1185
1245
1246
+
```shell
1247
+
yarn test --grep "Checkpoint2"
1186
1248
```
1187
1249
1188
1250
✅ Did the tests pass? You can dig into any errors by viewing the tests at `packages/hardhat/test/StakingOracle.ts`.
1189
1251
1252
+
</Tab>
1253
+
<Tablabel="Foundry">
1254
+
1255
+
**Foundry**
1256
+
1257
+
```shell
1258
+
yarn test --match-test "Checkpoint2"
1259
+
```
1260
+
1261
+
✅ Did the tests pass? You can dig into any errors by viewing the tests at `packages/foundry/test/StakingOracle.t.sol`.
1262
+
1263
+
</Tab>
1264
+
</Tabs>
1265
+
1190
1266
### Try it out!
1191
1267
1192
1268
🔄 Run `yarn deploy --reset` then test the staking oracle. Go to the `Staking` page and try registering your own node and reporting prices.
🧪 **Testing Strategy**: Each function you implement can be tested individually using the provided test suite. Run `yarn test` after implementing each function to verify your solution works correctly.
1304
1380
1381
+
<Tabs>
1382
+
<Tablabel="Hardhat">
1383
+
1305
1384
🔍 Open the `packages/hardhat/contracts/02_Optimistic/OptimisticOracle.sol` file to implement the optimistic oracle functionality.
1306
1385
1386
+
</Tab>
1387
+
<Tablabel="Foundry">
1388
+
1389
+
🔍 Open the `packages/foundry/contracts/02_Optimistic/OptimisticOracle.sol` file to implement the optimistic oracle functionality.
@@ -1485,12 +1572,27 @@ The bond amount should be the bond set on the assertion. The same amount that th
1485
1572
1486
1573
🔍 Run the following command to check if you implemented the functions correctly.
1487
1574
1488
-
```sh
1575
+
<Tabs>
1576
+
<Tablabel="Hardhat">
1489
1577
1578
+
**Hardhat**
1579
+
1580
+
```shell
1490
1581
yarn test --grep "Checkpoint4"
1582
+
```
1583
+
1584
+
</Tab>
1585
+
<Tablabel="Foundry">
1491
1586
1587
+
**Foundry**
1588
+
1589
+
```shell
1590
+
yarn test --match-test "Checkpoint4"
1492
1591
```
1493
1592
1593
+
</Tab>
1594
+
</Tabs>
1595
+
1494
1596
### 🥅 Goals:
1495
1597
1496
1598
- You can assert events with descriptions and time windows
@@ -1733,12 +1835,27 @@ Then set the winner to the proposer if the proposer was correct _or_ set it to t
1733
1835
1734
1836
🔍 Run the following command to check if you implemented the functions correctly.
1735
1837
1736
-
```sh
1838
+
<Tabs>
1839
+
<Tablabel="Hardhat">
1840
+
1841
+
**Hardhat**
1737
1842
1843
+
```shell
1738
1844
yarn test --grep "Checkpoint5"
1845
+
```
1846
+
1847
+
</Tab>
1848
+
<Tablabel="Foundry">
1849
+
1850
+
**Foundry**
1739
1851
1852
+
```shell
1853
+
yarn test --match-test "Checkpoint5"
1740
1854
```
1741
1855
1856
+
</Tab>
1857
+
</Tabs>
1858
+
1742
1859
### 🥅 Goals:
1743
1860
1744
1861
- Proposers can claim rewards for undisputed assertions
@@ -1861,14 +1978,31 @@ The important thing here is that it reverts if it is not settled and if it has b
1861
1978
1862
1979
🔍 Run the following command to check if you implemented the functions correctly.
1863
1980
1864
-
```sh
1981
+
<Tabs>
1982
+
<Tablabel="Hardhat">
1865
1983
1866
-
yarn test --grep "Checkpoint6"
1984
+
**Hardhat**
1867
1985
1986
+
```shell
1987
+
yarn test --grep "Checkpoint6"
1868
1988
```
1869
1989
1870
1990
✅ Did the tests pass? You can dig into any errors by viewing the tests at `packages/hardhat/test/OptimisticOracle.ts`.
1871
1991
1992
+
</Tab>
1993
+
<Tablabel="Foundry">
1994
+
1995
+
**Foundry**
1996
+
1997
+
```shell
1998
+
yarn test --match-test "Checkpoint6"
1999
+
```
2000
+
2001
+
✅ Did the tests pass? You can dig into any errors by viewing the tests at `packages/foundry/test/OptimisticOracle.t.sol`.
2002
+
2003
+
</Tab>
2004
+
</Tabs>
2005
+
1872
2006
### Try it out!
1873
2007
1874
2008
🔄 Run `yarn deploy --reset` then test the optimistic oracle. Try creating assertions, proposing outcomes, and disputing them.
@@ -1980,18 +2114,29 @@ Each oracle design solves different problems:
1980
2114
1981
2115
🎉 Well done on building the optimistic oracle system! Now, let's get it on a public testnet.
1982
2116
1983
-
📡 Edit the `defaultNetwork` to [your choice of public EVM networks](https://ethereum.org/en/developers/docs/networks/) in `packages/hardhat/hardhat.config.ts` (e.g., `sepolia`).
1984
-
1985
2117
🔐 You will need to generate a **deployer address** using `yarn generate`. This creates a mnemonic and saves it locally.
1986
2118
1987
2119
👩🚀 Use `yarn account` to view your deployer account balances.
1988
2120
1989
2121
⛽️ You will need to send ETH to your **deployer address** with your wallet, or get it from a public faucet of your chosen network.
1990
2122
2123
+
<Tabs>
2124
+
<Tablabel="Hardhat">
2125
+
2126
+
📡 Edit the `defaultNetwork` to [your choice of public EVM networks](https://ethereum.org/en/developers/docs/networks/) in `packages/hardhat/hardhat.config.ts` (e.g., `sepolia`).
2127
+
1991
2128
🚀 Run `yarn deploy` to deploy your optimistic oracle contracts to a public network (selected in `hardhat.config.ts`)
1992
2129
1993
2130
> 💬 Hint: You can set the `defaultNetwork` in `hardhat.config.ts` to `sepolia`**OR** you can `yarn deploy --network sepolia`.
1994
2131
2132
+
</Tab>
2133
+
<Tablabel="Foundry">
2134
+
2135
+
🚀 Run `yarn deploy --network sepolia` to deploy your optimistic oracle contracts to Sepolia testnet.
2136
+
2137
+
</Tab>
2138
+
</Tabs>
2139
+
1995
2140
---
1996
2141
1997
2142
## Checkpoint 9: 🚢 Ship your frontend! 🚁
@@ -2010,7 +2155,7 @@ Each oracle design solves different problems:
2010
2155
2011
2156
> Follow the steps to deploy to Vercel. It'll give you a public URL.
2012
2157
2013
-
> 🦊 Since we have deployed to a public testnet, you will now need to connect using a wallet you own or use a burner wallet. By default 🔥 `burner wallets` are only available on `hardhat`. You can enable them on every chain by setting `burnerWalletMode: "allNetworks"` in your frontend config (`scaffold.config.ts` in `packages/nextjs/`)
2158
+
> 🦊 Since we have deployed to a public testnet, you will now need to connect using a wallet you own or use a burner wallet. By default 🔥 `burner wallets` are only available on `localhost`. You can enable them on every chain by setting `burnerWalletMode: "allNetworks"` in your frontend config (`scaffold.config.ts` in `packages/nextjs/`)
2014
2159
2015
2160
#### Configuration of Third-Party Services for Production-Grade Apps.
2016
2161
@@ -2020,9 +2165,21 @@ This is great to complete your **Speedrun Ethereum**.
2020
2165
2021
2166
For production-grade applications, it's recommended to obtain your own API keys (to prevent rate limiting issues). You can configure these at:
2022
2167
2168
+
<Tabs>
2169
+
<Tablabel="Hardhat">
2170
+
2023
2171
- 🔷`ALCHEMY_API_KEY` variable in `packages/hardhat/.env` and `packages/nextjs/.env.local`. You can create API keys from the [Alchemy dashboard](https://dashboard.alchemy.com/).
2024
2172
- 📃`ETHERSCAN_API_KEY` variable in `packages/hardhat/.env` with your generated API key. You can get your key [here](https://etherscan.io/myapikey).
2025
2173
2174
+
</Tab>
2175
+
<Tablabel="Foundry">
2176
+
2177
+
- 🔷`ALCHEMY_API_KEY` variable in `packages/foundry/.env` and `packages/nextjs/.env.local`. You can create API keys from the [Alchemy dashboard](https://dashboard.alchemy.com/).
2178
+
- 📃`ETHERSCAN_API_KEY` variable in `packages/foundry/.env` with your generated API key. You can get your key [here](https://etherscan.io/myapikey).
2179
+
2180
+
</Tab>
2181
+
</Tabs>
2182
+
2026
2183
> 💬 Hint: It's recommended to store env's for nextjs in Vercel/system env config for live apps and use .env.local for local testing.
2027
2184
2028
2185
---
@@ -2054,3 +2211,18 @@ Oracles are fundamental infrastructure for the decentralized web. They enable sm
2054
2211
🚀 As you continue your blockchain development journey, you'll encounter many variations and combinations of these patterns. Understanding the fundamental trade-offs will help you choose the right oracle design for your specific use case.
2055
2212
2056
2213
🧠 Remember: the best oracle is the one that provides the right balance of security, speed, flexibility and cost for your application's needs!
2214
+
2215
+
## 🤖 AI-Guided Learning Mode (Optional)
2216
+
2217
+
This challenge supports an interactive AI learning mode. Instead of working through the checkpoints on your own, you can have an AI guide you step-by-step.
2218
+
2219
+
### Quick Start
2220
+
Run `/start` in your AI-enabled IDE (Cursor, VS Code with Claude, etc.) to begin.
2221
+
2222
+
### Commands
2223
+
-`/start` — Begin or resume the challenge
2224
+
-`/skip` — Skip current task (AI writes + explains the solution)
2225
+
-`hint` — Get contextual help anytime
2226
+
-`check` — Validate your current code
2227
+
2228
+
> 📝 Your progress is saved automatically in `.challenge-ai/progress.json`.
0 commit comments