Skip to content

Commit

Permalink
examples/rofl-oracle/oracle: Cleanup
Browse files Browse the repository at this point in the history
- move deploy script to task
- remove sapphire-hardhat as it's not needed
- simplify commands and docs
  • Loading branch information
matevz committed Sep 19, 2024
1 parent 0079a6b commit 55145c6
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 4,498 deletions.
22 changes: 11 additions & 11 deletions docs/rofl/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ You can find the entire project inside the Oasis SDK repository under
First we create the basic directory structure for the minimal runtime using
Rust's [`cargo`]:

```bash
```shell
cargo init rofl-oracle
```

Expand Down Expand Up @@ -271,7 +271,7 @@ max_expiration: 3
To then register a new ROFL app run the CLI as follows:
```bash
```shell
oasis rofl create policy.yml --network testnet --paratime sapphire
```

Expand Down Expand Up @@ -321,8 +321,8 @@ Configure the deployment private key and the ROFL app identifier (be sure to use
the identifier that you received during registration), then deploy the contract
by running:

```bash
PRIVATE_KEY="0x..." ROFL_APP_ID="rofl1..." npx hardhat run scripts/deploy.ts --network sapphire-testnet
```shell
PRIVATE_KEY="0x..." npx hardhat deploy rofl1... --network sapphire-testnet
```

After successful deployment you will see a message like:
Expand Down Expand Up @@ -359,7 +359,7 @@ previous step.
In order to quickly build the ROFL app you can use the helpers provided by the
Oasis CLI as follows:

```bash
```shell
oasis rofl build sgx --network testnet --paratime sapphire
```

Expand All @@ -384,7 +384,7 @@ Now that the app binaries are available, we need to update the policy with the
correct cryptographic identity of the app. To obtain the identity of the app
that was just built run:

```bash
```shell
oasis rofl identity rofl-oracle.orc
```

Expand Down Expand Up @@ -424,7 +424,7 @@ max_expiration: 3
Then to update the on-chain policy, run (using _your own app identifier_ instead
of the placeholder `rofl1qp55evqls4qg6cjw5fnlv4al9ptc0fsakvxvd9uw`):

```bash
```shell
oasis rofl update rofl1qp55evqls4qg6cjw5fnlv4al9ptc0fsakvxvd9uw \
--policy policy.yml \
--admin self \
Expand Down Expand Up @@ -486,7 +486,7 @@ oasis1qp66ryj9caek77kewkxxvjvkzypljhsdgvm5q34d
You can then [transfer some tokens] to this address on Sapphire Testnet to make
sure it will have funds to pay for registration fees:

```bash
```shell
oasis account transfer 10 oasis1qp66ryj9caek77kewkxxvjvkzypljhsdgvm5q34d \
--network testnet --paratime sapphire
```
Expand All @@ -500,7 +500,7 @@ In order to check that the ROFL app is running and has successfully registered
on chain, you can use the following command (using _your own app identifier_
instead of the placeholder `rofl1qp55evqls4qg6cjw5fnlv4al9ptc0fsakvxvd9uw`):

```bash
```shell
oasis rofl show rofl1qp55evqls4qg6cjw5fnlv4al9ptc0fsakvxvd9uw \
--network testnet --paratime sapphire
```
Expand Down Expand Up @@ -548,8 +548,8 @@ their registrations to ensure they don't expire.
In order to check that the oracle is working, you can use the prepared
`oracle-query` task in the Hardhat project. Simply run:

```bash
PRIVATE_KEY="0x..." npx hardhat oracle-query 0x1234845aaB7b6CD88c7fAd9E9E1cf07638805b20 --network sapphire-testnet
```shell
npx hardhat oracle-query 0x1234845aaB7b6CD88c7fAd9E9E1cf07638805b20 --network sapphire-testnet
```

And you should get an output like the following:
Expand Down
39 changes: 38 additions & 1 deletion examples/runtime-sdk/rofl-oracle/oracle/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,41 @@
# Simple ROFL Oracle Contract

See the ROFL tutorial for some examples on how to use this project.
For the ROFL Oracle smart contract delpoyment you will need the following
information:

- the ROFL app ID (rofl1...)
- the deployer's private key
- the network you're deploying to (sapphire-testnet, sapphire-localnet,
sapphire)

First install dependencies and compile the smart contract:

```shell
npm install
npx hardhat compile
```

Then, prepare your hex-encoded private key for paying the deployment gas fee
and store it as an environment variable:

```shell
export PRIVATE_KEY=0x...
```

Finally, deploy the contract, provide the ROFL App ID and the network:

```shell
npx hardhat deploy rofl1... --network sapphire-localnet
```

Once your Oracle ROFL is running, it will submit the observations to the smart
contract deployed above. You can fetch the data stored on-chain by running:

```shell
npx hardhat oracle-query 0xbdEd0D2bf404bdcBa897a74E6657f1f12e5C6fb6 --network sapphire-localnet
```

For more information check out the [ROFL tutorial].

[ROFL tutorial]: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/app.md

3 changes: 1 addition & 2 deletions examples/runtime-sdk/rofl-oracle/oracle/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { HardhatUserConfig } from "hardhat/config";
import '@oasisprotocol/sapphire-hardhat';
import "@nomicfoundation/hardhat-toolbox";

import "./tasks/query";
import "./src/tasks";

const config: HardhatUserConfig = {
solidity: "0.8.19",
Expand Down
Loading

0 comments on commit 55145c6

Please sign in to comment.