Polkadot Offchain Worker
This page contains an overview over the DIA offchain worker for Polkadot
DIA offers a flexible oracle solution for Polkadot. Our offchain worker can be instantiated by any node operator. You can integrate it into your parachain and access the DIA API using the offchain worker.
How it works
The DIA offchain worker (ocw) is a component that can be ported to parachains and is located in this repository.
This offchain worker (ocw) gets data from a DIA API endpoint and writes an event as signed transaction for all local keys with subkey type dia!
. It can be used to retrieve any data from the DIA API. The offchain worker "lives" in a node deployed to a parachain and needs an active Internet connection. It acts as an oracle that provides data for any application inside the specific parachain.
Installation
To add the ocw (offchain worker) pallet to your node, add it to your runtime like this (in this repository already done):
Edit your
runtime/Cargo.toml
:Add this section specifying the ocw path under
[dependencies]
:Add
"pallet-dia-ocw/std",
at the[features]
section:
Edit
runtime/src/lib.rs
like this:Add the ocw trait:
Insert
DIAOCW: pallet_dia_ocw::{Module, Call, Event<T>},
to theRuntime
enum:
Usage
For each block, this offchain worker automatically adds a signed transaction of the endpoint specified in its source code. The signer account needs to be funded appropriately to pay the transaction fees.
Local development mode
Start the node and dev network by running
cargo run -- --dev --tmp
.Create an account or add a subkey to an existing account, e.g. the example account
Alice
via RPC:
The ocw should now write values from the DIA API to the parachain.