12 votes

How to find how many transactions are pending from address to be added to block?

The author_pendingExtrinsics RPC provides the list of pending extrinsics that is in the pool. This is retrieved on a per-node basis, i.e. it will list the extrinsics that is available for the specific ...
Jaco's user avatar
  • 5,865
10 votes
Accepted

How to convert substrate Specific Types(Option<BalanceOf<T>> ) to Rust Primitive types (U64)?

You'll see that Currency::Balance is bound to AtLeast32BitUnsigned which by being bound to BaseArithmetic is bound to implement TryInto<u64>. Therefore the most obvious code is something like: ...
Gav's user avatar
  • 2,671
6 votes
Accepted

How key-values database and Merkle Tree works together on Substrate

You should check out the Storage Deep Dive here: https://www.shawntabrizi.com/substrate/substrate-storage-deep-dive/ If you have more specific questions, feel free to open another post. Some ...
Shawn Tabrizi's user avatar
  • 16k
5 votes
Accepted

I'm struggling to understand the concept of runtime calls, RPC calls, and extrinsics in Substrate

A blockchain is basically a database whose current state depends entirely on the data within the blocks. Each block contains a bunch of transactions*, and so the only way for a user to update the ...
jsdw's user avatar
  • 1,335
4 votes
Accepted

How to understand [runtime-interface] and `Externalities`?

In general, it is not advised to look at the output of any macro at all, if you are not developing it ;) If there are questions that you want to know specifically or if the docs are missing ...
bkchr's user avatar
  • 11.1k
3 votes

How can I create a currencies.transfer transaction?

Thank you all and I have create the unsinged transaction successfully. The 'currencyId' parameter in the rpc request should start with "Token:" { "key": "//1234567890"...
Lyn's user avatar
  • 31
3 votes

How to solve the issue"Element "asset_id" of struct is missing in given value" when I send a token transaction

Are you sure you have the latest version of packages substrate-interface==1.2.2 and scalecodec==1.0.34? Because I can remember older versions of scalecodec don't have the 'signed_extensions' support ...
Arjan's user avatar
  • 151
2 votes
Accepted

How to find how many transactions are pending from address to be added to block?

thanks guys for offering answers. I got partial answer from @Luna. Here is solution I came up with. Problem: After firing n number of transactions in burst, from same address, I wanted api which will ...
pravin k's user avatar
  • 111
2 votes

Retrieve reason of fail substrate rpc call

exactly amount if to be accurate If by this you mean you are trying to drain your account to Zero, check ExistenceRequirement and how is the fee withdrawal handled in Substrate using the KeepAlive ...
TMichel's user avatar
  • 183
2 votes

Can generate an address by mnemonic with the sdk substrate-interface?

You need to provide the SS58 prefix to the create_from_mnemonic function to make it generate a Kusama address as opposed to a generic Substrate address: from substrateinterface import Keypair # 2 for ...
Oliver Tale-Yazdi's user avatar
2 votes

How to obtain the staking amount for non-active validators?

I believe you will need to do a few queries here to get the data you want: Get all validator stash accounts from iterating over the Validators storage map Get all the controller accounts by mapping ...
Shawn Tabrizi's user avatar
  • 16k
2 votes
Accepted

How to determine what parameter to pass into substrate.query() to query a storage_function from polkascan's py-substrate-interface?

The call is complaining about you sending an integer. You will be getting an integer from get_block_number which you're passing in a block_hash field: block = substrate.get_block_number(hash) # this ...
forgetso's user avatar
  • 1,492
2 votes
Accepted

How to get the balance for a specific account using py-substrate

The query_map function queries multiple entries of a map. If you just want a single value, you can use query instead. Try the following on a local Substrate or Polkadot development node to see how it ...
Oliver Tale-Yazdi's user avatar
2 votes

Substrate learning resources

What you are looking for is the Substrate Tutorials. Also this post in StackExchange from Bruno is the best summary out there to start learning Substrate. And I would like to add a few links to it ...
Alex Bean's user avatar
  • 5,702
2 votes

How to generate node information?

I'm not sure if sc_cli provides these. AFAIK it didn't. But here is a general solution. Check this https://github.com/darwinia-network/darwinia/blob/12f3123d8c4d6fb8896d3f42dadb7b99a168fde1/cli/src/...
AurevoirXavier's user avatar
2 votes

How to start a local substrate node using python substrate interface

As you note in your question py-substrate-interface is just used to interface with a node, a node that is already running. If you are interested in discovering more about how to set up and run your ...
Alejandro Martínez's user avatar
2 votes
Accepted

How to get a list of all the smart contract account ids and WASM blobs on a parachain

I am sharing with you the code about how to do it using PolkadotJS. Using python should be calling the same functions. First connect to the parachain you want to query const wsProvider = new ...
Alex Bean's user avatar
  • 5,702
2 votes

Pagination issues in py-substrate-interface

The easiest way to handle query_map is use it as an iterator instead of manual last-key tracking. For example all accounts of System::Account for Kusama: from substrateinterface import ...
Oliver Tale-Yazdi's user avatar
1 vote

construct_runtime macro panics in a mock environment while it builds in normal runtime

I'd suggest to take this pallet as a template for yours. Is a pallet template from the Substrate Developer Hub repo. In this you can see how to mock the environment: frame_support::construct_runtime!( ...
Alex Bean's user avatar
  • 5,702
1 vote
Accepted

How To Adjust The Fees On A Running Substrate Chain?

In general a runtime upgrade is the way to go, as @Purple_Turtle pointed out. (You could also try to hack around it with System::set_storage to overwrite the fee multiplier with PolkadotJS, but that ...
Oliver Tale-Yazdi's user avatar
1 vote

Pallet Call Indicies are Conflicting Error

A macro was introduced to pallets to explicitly define an index for each runtime call. If the pallet you are working on uses this macro, ensure that newly added calls also have a call index. E.g.: #[...
Ross's user avatar
  • 161
1 vote
Accepted

Get a block based on timestamp from python substrate interface

You can use a binary search for this. There is no API which will give this to you without some kind of search on your side as blocks are not indexed by timestamp. You can also estimate the start of ...
Shawn Tabrizi's user avatar
  • 16k
1 vote

final_checks() on Executive module

The new header should have the new storage root. So when you are done executing the whole block, you can check that your current state root, after all extrinsics and state changes, matches what is ...
Shawn Tabrizi's user avatar
  • 16k
1 vote

How to get specific extrinsic using python substrate interface

If you wait for the extrinsic to be finalized by setting wait_for_finalization=True in the submit_extrinsic call, you will get back relevant information in the receipt. The best resource for this is ...
Nate Armstrong's user avatar
1 vote
Accepted

How to submit a transaction form the root/sudo acount using python substrate interface

You need to have the Sudo pallet deployed, which is often the case in development networks. Then you can wrap the call in Sudo::sudo and sign it with the sudo key. Example of Alice being sudo and ...
Oliver Tale-Yazdi's user avatar
1 vote

How can I create a currencies.transfer transaction?

So the root of the problem is directly in the error. The dest: 1234 points to Decoding 1234: Invalid decoded address checksum which is alluding to the fact that the address is in an incorrect format. ...
Tarik Gul's user avatar
  • 1,106
1 vote

How to determine what parameter to pass into substrate.query() to query a storage_function from polkascan's py-substrate-interface?

To get more information how to format the paramaters of a specific storage function, you can check out: https://github.com/polkascan/py-substrate-interface#type-information-about-how-to-format-...
Arjan's user avatar
  • 151
1 vote

How to subscribe the new pending transaction of polkadot in substrate python

I think what you mean is the author_pendingExtrinsics RPC call, so that would be something like: result = substrate.rpc_request("author_pendingExtrinsics", [])
Arjan's user avatar
  • 151
1 vote

Python substrate-interface discovering which params need to be passed into query function for parallel API?

You can use the storage_function.get_param_info() to get more information about the param types: storage_function = substrate.get_metadata_storage_function('AMM', 'Pools') param_info = ...
Arjan's user avatar
  • 151
1 vote

How key-values database and Merkle Tree works together on Substrate

One of the best in class resources for an overview IMHO is the Sub0 storage deep dive by Shawn Tabrizi and the presentation created here. The primary advanced docs on storage are also good to get more ...
Nuke's user avatar
  • 1,832

Only top scored, non community-wiki answers of a minimum length are eligible