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
4
votes
1 answer

How do you format balances with the Polkadot JS API?

I would like to get the balance of a user formatted using the base unit of the Substrate chain. When I use toHuman(), I get an opinionated formatting which includes a prefix like so: let account = await…
Shawn Tabrizi
  • 12,206
  • 1
  • 38
  • 69
4
votes
1 answer

Connect via WSS to Polkadot Full Noder running on local network failed

I have setup a Full Node running at a local server at 192.168.2.254. I'm just trying to make a simple script which is basically subscribe to new heads on the blockchain. const { ApiPromise, WsProvider } = require('@polkadot/api'); async function…
4
votes
2 answers

How do I save a string value on Substrate's smart contract platform, ink?

I initially tried the implementation as taught in this question. (How can I save string value on Substrate) However, an error occurred in relation to "ink_abi" and the struct could not be defined. Looking at the latest "ink! example"(), I tried to…
s.Takahashi
  • 469
  • 4
  • 15
4
votes
2 answers

Event pattern in Substrate

Event pattern in blockchain solutions is well known, could anyone from Substrate's Team link to the pattern in Substrate code? I just want to understand the pattern in the context of Substrate framework and Rust language.
Tomasz Waszczyk
  • 2,680
  • 5
  • 35
  • 73
4
votes
1 answer

Converting between AccountId32 and AccountId in Substrate

I have a requirement where i get passed in some bytes and i need to create an accountId from it in Substrate 2.0. Is there a way to convert between AccountId32 and ::AccountId in the runtime (FRAME) ? Or to create an…
Nahu
  • 143
  • 10
4
votes
1 answer

Parity Substrate - blocks are not being finalized

Problem I am running a private chain with 2 local nodes using custom accounts and keys. Peer discovery works, but blocks are not being finalized. Idle (1 peers), best: #0 (0xb166…8ad2), finalized #0 (0xb166…8ad2), Idle (1 peers), best: #0…
TMichel
  • 4,336
  • 9
  • 44
  • 67
4
votes
3 answers

How to bind to 0.0.0.0 instead of localhost for Docker purposes

I am currently trying to wrap the entire Node in a Docker container. However substrate when i run it runs on localhost. I cannot seem to find a way to bind it to 0.0.0.0 since Docker doesn't play too nice binding to localhost due to the nature of…
Byrd
  • 867
  • 3
  • 12
  • 24
4
votes
1 answer

Is there any way to make a specific information on blockchain can only be queried by one specific account?

just want to know, is there any way to make specific information on the blockchain can only be queried by one specific account? More exactly, I am thinking let the user put their information on chain and give specific account access, so only that…
Alex W
  • 166
  • 9
4
votes
1 answer

Kusama - Provided Host header is not whitelisted

having started the kusama node as a service with polkadot --port 30333 --rpc-external --rpc-port 9933 --ws-external --ws-port 9944 Now im trying to call the node with a POST request for http://IP:9933 and this JSON payload: {"id":1,…
Vindberg
  • 1,502
  • 2
  • 15
  • 27
4
votes
1 answer

In srml_support::storage::StorageMap, what is the difference between get() and take()

In srml_support::storage::StorageMap, what is the difference between fn get() and fn take()?
Jimmy Chu
  • 972
  • 8
  • 27
3
votes
1 answer

How to generate the public key from Polkadot Address from Substrate Side

I'm generating a Public key from PolkadotJS as follows const keyring = new Keyring({ type: "sr25519" }); const account = keyring.addFromUri("//Bob", { name: "Bob default" }); // encoded public key let public_key =…
not 0x12
  • 19,360
  • 22
  • 67
  • 133
3
votes
2 answers

Failed to load manifest for dependency

I am trying to import some primitives into pallet in substrate but when I execute cargo check I get this error: failed to load manifest for dependency 'name of primitives' Dex pallet:…
P.E
  • 101
  • 2
  • 8
3
votes
1 answer

How to create an account programmatically with Substrate?

Besides my substrate network, I want to create a wallet app. When the user opens it, the account on the network should be created programmatically, I figured out how to generate mnemonic and the key pair, but how do i put my keypair on the…
3
votes
2 answers

Is it feasible to implement a Raft/PBFT like (leader election between authorized nodes) consensus algorithm in the substrate?

I'm new to the substrate. I'm trying to improve the availability of block generation of permissioned networks by substituting Aura with Raft/PBFT like consensus algorithm. I'm referring to an algorithm that solves the "who can generate blocks"…
Lavoris
  • 71
  • 5
3
votes
0 answers

Substrate Genesis Configuration newly added pre funded accounts not appearing in polkadotjs/app or in Substrate frontend template

In Substrate Node Template Genesis Config I have added a new Account named Golem in ChainSpec local_test_net pub fn local_testnet_config() -> Result { let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm…
not 0x12
  • 19,360
  • 22
  • 67
  • 133