Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 28

Questions about the Rust programming language, the primary language used in the Substrate ecosystem.

3 votes

How to store date on storage?

It is not recommended to store and use dates on chain, since dates are not a native measurement of the blockchain. Instead you can use the BlockNumber type, which is going to be a much better unit for …
Shawn Tabrizi's user avatar
  • 16.3k
2 votes
Accepted

Unable to calculate logarithm of a number error method log10 ln

You really cannot use floating point numbers in the runtime since floating point numbers are not deterministic. You can learn a lot more why with other online resources like this. Instead you should b …
Shawn Tabrizi's user avatar
  • 16.3k
8 votes
Accepted

How can I have some of the functions in separate file?

Must all be within the: #[frame_support::pallet] pub mod pallet { ... } And unfortunately, due to Rust not handling cross file macros, these must all be together. …
Shawn Tabrizi's user avatar
  • 16.3k
3 votes
Accepted

T::Balance ... associated type `Balance` not found for `T`

Substrate chains are designed to be completely modular and without any assumptions about the underlying blockchain. This means that Balances are not necessarily a first class citizen within your runti …
Shawn Tabrizi's user avatar
  • 16.3k
0 votes

Attempting to build multiple runtimes, stopped by `AccountNonceApi_account_nonce` is already...

Each client for the different networks are behind feature flags in the Polkadot repo. Take a look at: polkadot/cli/Cargo.toml # Configure the native runtimes to use. Polkadot is enabled by default. # …
Shawn Tabrizi's user avatar
  • 16.3k
5 votes
Accepted

Missing trait problem

You are really mixing up what the generic types mean to you. In one case, you have T represent the AccountId directly, and in the other case you have it represent your Config. Here is a minimal sample …
Shawn Tabrizi's user avatar
  • 16.3k
1 vote

Examples of Substrate Benchmarking

the official documentation Seems like a pretty good place to learn about benchmarking to me: https://github.com/paritytech/substrate/tree/master/frame/benchmarking Beyond that: 3 Hour Video on Benc …
Shawn Tabrizi's user avatar
  • 16.3k
10 votes

How to call extrinsic functions externally from rust?

The easiest way to do this is with JavaScript and using the Polkadot JS APIs. An example for batching transactions can be found here: // construct a list of transactions we want to batch const txs = [ …
Shawn Tabrizi's user avatar
  • 16.3k
1 vote

Best way to connect my substrate node with android app

Not sure how up to date this library stays, but here is a Substrate library written in Java: https://github.com/emeraldpay/polkaj And here is one in Kotlin: https://github.com/NodleCode/substrate-clie …
Shawn Tabrizi's user avatar
  • 16.3k
6 votes
Accepted

What is the difference between dependencies and dev-dependencies in Cargo.toml

This is a general Rust concept: https://doc.rust-lang.org/rust-by-example/testing/dev_dependencies.html Basically, [dev-dependencies] are the crates you only need for compiling and running tests. … Normally, the Rust compiler checks for and prohibits any cyclic dependencies. For [dev-dependencies], this check is ignored, allowing two crates to be dependent on eachother specifically for tests. …
Shawn Tabrizi's user avatar
  • 16.3k
4 votes

Event encoding in substrate pallet

Yes, event name is superficial. What actually matters is how the pallet event is encoded into bytes. Pallet events are encoded such that the first byte represents the pallet index, and the second byte …
Shawn Tabrizi's user avatar
  • 16.3k
3 votes
Accepted

How to create an iterator for a child storage trie?

You can take a look at the crowdloan pallet in Polkadot to see an example of manipulating and using a child-trie. https://github.com/paritytech/polkadot/blob/master/runtime/common/src/crowdloan/mod.rs …
Shawn Tabrizi's user avatar
  • 16.3k
3 votes
Accepted

Balance division in Substrate runtime

Balances in most substrate chains are u128, however this is usually opaque, allowing developers to change the type if they want. Converting the value explicitly to u128 is definitely not the right thi …
Shawn Tabrizi's user avatar
  • 16.3k
4 votes
Accepted

How to convert Vec<u8> to u32 in Substrate runtime?

While you don't have access to std, you do have access to core, and that should have all the tools you need. For example, this should work fine inside of the runtime environment: fn string_to_number(t …
Shawn Tabrizi's user avatar
  • 16.3k
5 votes
Accepted

Cannot infer type for type parameter 'T'

Rather than call Investor::contribute(who,dev.account_id,rent); Seems you should call: Investor::<T::AccountId, u32>::contribute(who,dev.account_id,rent); And just be explicit with your type definiti …
Shawn Tabrizi's user avatar
  • 16.3k

15 30 50 per page