substrate-offchain-worker-demo icon indicating copy to clipboard operation
substrate-offchain-worker-demo copied to clipboard

Fetching cryptocurrency prices using off-chain workers

trafficstars

Substrate Off-chain Worker Demo

This repository is built based on Substrate Node Template v3.0.0+monthly-2021-10.

The purpose is to demonstrate what off-chain worker could do, and how one would go about using it.

Run

  1. First, complete the basic Rust setup instructions.

  2. To run it, use Rust's native cargo command to build and launch the template node:

cargo run --release -- --dev --tmp
  1. To build it, the cargo run command will perform an initial build. Use the following command to build the node without launching it:
cargo build --release

Since this repository is based on Substrate Node Template, it's README applies to this repository as well.

About Off-chain Worker

  • The core of OCW features are demonstrated in pallets-ocw, and pallets-example-offchain-worker.

    Note that in order for the offchain worker to run, we have injected Alice key in node/service.rs

  • Goto docs/README.md to learn more about off-chain worker (extracted from Substrate Recipes, based on Substrate v3).

  • Review the code of Offchain Worker Example Pallet within Substrate and its rustdoc. This pallet is also added in this repository.