29 major breaking releases

32.0.0 Apr 8, 2024
31.0.0 Mar 18, 2024
30.0.0 Feb 26, 2024
29.0.0 Feb 13, 2024
0.0.0 Nov 21, 2022

#212 in Magic Beans

Download history 7/week @ 2024-01-18 10/week @ 2024-02-08 20/week @ 2024-02-15 183/week @ 2024-02-22 38/week @ 2024-02-29 5/week @ 2024-03-07 97/week @ 2024-03-14 19/week @ 2024-03-21 15/week @ 2024-03-28 92/week @ 2024-04-04 21/week @ 2024-04-11

156 downloads per month
Used in pallet-examples

MIT-0 license

2.5MB
43K SLoC

Offchain Worker Example Pallet

The Offchain Worker Example: A simple pallet demonstrating concepts, APIs and structures common to most offchain workers.

Run cargo doc --package pallet-example-offchain-worker --open to view this module's documentation.

This pallet serves as an example showcasing Substrate off-chain worker and is not meant to be used in production.

Overview

In this example we are going to build a very simplistic, naive and definitely NOT production-ready oracle for BTC/USD price. Offchain Worker (OCW) will be triggered after every block, fetch the current price and prepare either signed or unsigned transaction to feed the result back on chain. The on-chain logic will simply aggregate the results and store last 64 values to compute the average price. Additional logic in OCW is put in place to prevent spamming the network with both signed and unsigned transactions, and custom UnsignedValidator makes sure that there is only one unsigned transaction floating in the network.

License: MIT-0

Dependencies

~17–34MB
~547K SLoC