Move all example pallets under examples folder. (#10215)

* Put all examples under one folder

Signed-off-by: Jimmy Chu <jimmychu0807@gmail.com>

* Updated Cargo.toml

Signed-off-by: Jimmy Chu <jimmychu0807@gmail.com>

* updated for ci script

Signed-off-by: Jimmy Chu <jimmychu0807@gmail.com>

* update

Signed-off-by: Jimmy Chu <jimmychu0807@gmail.com>

* Added notes that example pallets are not meant to be used in production.

Signed-off-by: Jimmy Chu <jimmychu0807@gmail.com>

* updated

Signed-off-by: Jimmy Chu <jimmychu0807@gmail.com>
This commit is contained in:
Jimmy Chu
2021-11-10 16:11:28 +08:00
committed by GitHub
parent 617e2cc75e
commit db59cfcf14
18 changed files with 81 additions and 60 deletions
@@ -0,0 +1,29 @@
<!-- markdown-link-check-disable -->
# 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.
- [`pallet_example_offchain_worker::Trait`](./trait.Trait.html)
- [`Call`](./enum.Call.html)
- [`Module`](./struct.Module.html)
**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: Unlicense