substrate

How can I initialize a user's balance in a Substrate blockchain?

心已入冬 提交于 2019-12-25 02:12:38
问题 When I start my Substrate blockchain, I want to initialize users with some free balance. How can I achieve this? What if my chain is already running and I do not want to restart it? 回答1: Genesis Configuration The best way to set up your Substrate users with some initial free balance is to update your chain_spec.rs file such that users are given units at the genesis block of your blockchain. This genesis configuration happens through the Balances module: fn testnet_genesis(initial_authorities:

How to implement the EVM Trait for a Substrate Runtime?

↘锁芯ラ 提交于 2019-12-12 16:48:29
问题 Following the adding a module to your runtime, I'm trying to implement the Parity Substrate paint-evm trait for the Dothereum Runtime. The EVM module trait is defined as follows: pub trait Trait: Trait + Trait { type FeeCalculator: FeeCalculator; type ConvertAccountId: ConvertAccountId<Self::AccountId>; type Currency: Currency<Self::AccountId>; type Event: From<Event> + Into<Self::Event>; type Precompiles: Precompiles; } The adding a module tutorial here, however, is a bit vague and

In the oo7 Substrate UI, Alice has zero funds

一笑奈何 提交于 2019-12-11 15:15:24
问题 In the Substrate-UI using the Bonds library (oo7), it shows that "Alice" has zero funds on a development chain. I also notice that some accounts are labeled as ed25519 and other are sr25519 . How can I repair this and gain access to the correct Alice? 回答1: Recently, Substrate changed the default cryptography for accounts and transactions signing from ed25519 to sr25519 . Depending on what combination of software you are using (node, UI, etc...) and what local storage items you have stored

What is the purpose of `pub` in decl_storage?

﹥>﹥吖頭↗ 提交于 2019-12-11 10:03:51
问题 When implementing a runtime module in substrate, given the following storage decl_storage! { trait Store for Module<T: Trait> as CatAuction { Kitties get(kitties): map T::Hash => Kitty<T::Hash, T::Balance>; KittyOwner get(owner_of): map T::Hash => Option<T::AccountId>; OwnedKitties get(kitties_owned): map T::AccountId => T::Hash; pub AllKittiesCount get(all_kitties_cnt): u64; Nonce: u64; // if you want to initialize value in storage, use genesis block } } What is the purpose of pub in front

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

ε祈祈猫儿з 提交于 2019-12-10 15:59:55
问题 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... 回答1: For the latest in Substrate master Substrate has removed As in favor of From / Into . An assumption is made that all types are at least u32 . From the trait SimpleArithmatic , the following are implemented: From : u8 , u16 , u32 TryFrom : u64 , u128 , usize TryInto : u8

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

断了今生、忘了曾经 提交于 2019-12-10 14:49:02
问题 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 module? Something along these lines: /// In ModuleA pub type IndexType = u64; decl_storage! { trait Store for Module<T: Trait> as ModuleA { pub MyIndexCount get(my_index_count): Option<IndexType>; } } And then inside ModuleB - what do I need to do to

Substrate has runtime versioning. What is the purpose and use case for these?

筅森魡賤 提交于 2019-12-10 10:48:57
问题 In the main lib.rs of substrate's runtime, (and also in the template node) there are several version attributes which can be changed - I'm guessing for tracking various build versions - but it's not clear how we are to use these in our own projects. 1) What are they for? What are the expectations for incrementing these in our own projects? 2) Are any one of these or combination intended to indicate incompatibility with a prior version of our runtimes, for example an incrementation of this