#run-time #substrate #pallet #sum #items #api #blockchain

no-std sum-storage

A pallet with two storage items whose sum is exposed via a custom runtime API

1 release (0 unstable)

2.0.0-alpha.6 Apr 22, 2020

#41 in #sum

GPL-3.0-or-later

8KB
119 lines

Substrate Recipes 🍴😋🍴

Build Status

Lines of Code Try on playground

A Hands-On Cookbook for Aspiring Blockchain Chefs

Get Started

Ready to roll up your sleeves and cook some blockchain? 😋

Repository Structure

There are five primary directories in this repository:

  • Text: Source of the book written in markdown. This text describes the code in the other three directories.
  • Pallets: Pallets for use in FRAME-based runtimes.
  • Runtimes: Runtimes for use in Substrate nodes.
  • Consensus: Consensus engines for use in Substrate nodes.
  • Nodes: Complete Substrate nodes ready to run.

The book is built with mdbook and deployed via github pages.

Building This Book Locally

Building the book requires mdBook, ideally the same version that rust-lang/rust uses in this file. To get it:

$ cargo install mdbook --vers [version-num]

To build the book, type:

$ mdbook build

The output will be in the book subdirectory. To check it out, open up book/index.html in a web browser, or to serve the book locally, type:

$ mdbook serve

The default address to view the book will be located at http://localhost:3000 .

License

The Substrate Recipes are GPL 3.0 Licensed It is open source and open for contributions.

Using Recipes in External Projects

The pallets and runtimes provided here are tested and ready to be used in other Substrate-based blockchains. The big caveat is that you must use the same upstream Substrate version throughout the project.


lib.rs:

A simple pallet with two storage values. The pallet itself does not teach any new concepts. Rather we use this pallet as demonstration case as we demonstrate custom runtime APIs. This pallet supports a runtime API which will allow querying the runtime for the sum of the two storage items.

Dependencies

~7MB
~131K SLoC