Questions tagged [substrate]

Substrate is a framework for blockchain prototyping and development written in Rust. General questions about Substrate should be asked on https://substrate.stackexchange.com

Substrate is a framework for prototyping and development written in . At its heart, Substrate is a combination of three technologies: , and AfG Consensus. It is both a library for building new blockchains and a skeleton key of a blockchain client, able to synchronize to any Substrate-based chain.

Substrate chains have three distinct features that make them next-generation: a dynamic, self-defining state-transition function (STF), light-client functionality from day one and a progressive consensus algorithm with fast block production and adaptive, definite finality.

The STF, encoded in WebAssembly, is known as the runtime. This defines the execute_block function and can specify everything from the staking algorithm, transaction semantics, logging mechanisms and procedures for replacing any aspect of itself or of the blockchain’s state (governance). Because the runtime is entirely dynamic, all of these can be switched out or upgraded at any time. A Substrate chain is very much a living organism.

587 questions
43
votes
5 answers

Unable to specify `edition2021` in order to use unstable packages in Rust

I want to run an example via Cargo but I am facing an error: error: failed to parse manifest at `/Users/aviralsrivastava/dev/subxt/Cargo.toml` The full stacktrace is: error: failed to parse manifest at…
Aviral Srivastava
  • 4,058
  • 8
  • 29
  • 81
20
votes
1 answer

In Substrate, What is the difference between Babe, Aura, and Grandpa

Substrate supports "pluggable consensus" so a developer can choose from among several consensus algorithms. It comes standard with four algorithms: Aura Babe Proof of Work Grandpa Some of these (eg babe and grandpa) can even be used together in a…
JoshOrndorff
  • 1,591
  • 9
  • 19
18
votes
1 answer

When should I build a Substrate Runtime Module versus a Substrate Smart Contract?

What are the differences between developing a Substrate Runtime Module and a Substrate Smart Contract (for example with the ink! language)? What are some examples of applications which are best written in one form or the other?
mountbranch
  • 334
  • 2
  • 7
16
votes
2 answers

How do you convert between Substrate specific types and Rust primitive types?

Using the Substrate blockchain framework, how can I convert between Substrate specific types and Rust primitive types and vice versa? For example: Convert a time (T::Moment) to a u64 Convert a u64 to a T::Balance etc...
Shawn Tabrizi
  • 12,206
  • 1
  • 38
  • 69
9
votes
7 answers

some error failed to run custom build command for `librocksdb-sys v6.11.4`

I tried to create my first substrate chain. Create Your First Substrate Chain But I got some error while compiling substrate. failed to run custom build command for librocksdb-sys v6.11.4 Does anybody know how to fix this problem?
aoi
  • 155
  • 1
  • 4
9
votes
1 answer

How do we use the balances pallet instead of the system pallet to store the balances

If we take a look at the polkadot js documentation we can see the following note: This is only used in the case that this pallet is used to store balances. Now how do we use the balances pallet to store the balances? because we also have the…
Noah Bergh
  • 493
  • 4
  • 14
8
votes
1 answer

How to correctly upgrade a runtime on Substrate node?

Followed the create a first substrate chain it all works good. And then I want to go one step further to customize my on the demo.rs file, here is what I am doing: Totally replace code in demo.rs with code here, there is event involved now . update…
Haven
  • 7,808
  • 5
  • 25
  • 37
8
votes
1 answer

In Substrate is there a way to use storage and functions from one custom module in another?

I have seen the Substrate Tutorial on creating crates of individual Substrate Runtime modules here in order to re-use the functionality, but I wondered if there is a way for one custom module to access the storage or functions from another custom…
T9b
  • 3,312
  • 5
  • 31
  • 50
8
votes
1 answer

How to do floating point arithmetic in substrate runtime

How can I do math on floating point values in substrate runtime. As a simple example imagine I want to keep track of an interest rate in a decentralized finance. I can prototype by using the percentage as an integer let rate = 2; let dividend =…
JoshOrndorff
  • 1,591
  • 9
  • 19
7
votes
2 answers

Substrate node template Cannot create a runtime error=Other("cannot deserialize module: UnknownOpcode(192)")

I'm trying to follow this procedure https://docs.substrate.io/tutorials/build-a-blockchain/build-local-blockchain/#start-the-local-node to start the local node. But it always gives me the error: ➜ substrate-node-template git:(my-wip-branch)…
7
votes
2 answers

Error encountered could not complete yarn install of substrate front end template

Followed the installation steps provided here https://docs.substrate.io/tutorials/v3/create-your-first-substrate-chain/ Steps taken with node version v16.14.0 git clone https://github.com/substrate-developer-hub/substrate-front-end-template yarn…
John
  • 401
  • 3
  • 8
7
votes
1 answer

Runtime Building: String not found in this scope

A common problem substrate developers might run into: developing a custom pallet to store the mapping into storage with common types, such as String. As an example: #[derive(Encode, Decode, Clone, Default, RuntimeDebug)] pub struct ClusterMetadata…
Nuke
  • 1,032
  • 7
  • 13
7
votes
2 answers

How to re-use a Substrate pallet multiple times within the same runtime?

I want to have multiple currencies within the same runtime. There is Balances pallet plugged into the default node template, but if I've got it right it can handle only one currency. How can I re-use the pallet multiple times?
7
votes
2 answers

How to solve Substrate `duplicate lang item in crate 'std' (which 'myexternalcrate' depends on): 'panic_impl' conflict with sr-io

I'm using an extern crate in my Substrate 1.0 runtime module (based on node-template) which gives a compile error of duplicate lang item in crate 'std' (which 'myexternalcrate' depends on): 'panic_impl'. = note: first defined in crate `sr_io`…
T9b
  • 3,312
  • 5
  • 31
  • 50
7
votes
2 answers

What is the cost of event storage in substrate?

While implementing my chain logic I was wondering whether to use events at all since they might cost the node extra storage for the event logs. What is the actual storage cost involved here? Do the logs get purged automatically at some point?
vim
  • 1,098
  • 9
  • 21
1
2 3
39 40