8
votes
Accepted
Get account transactions using Substrate API
Substrate indeed covers quite many use-cases, not just transferring coins from one account to another, and some of that complexity will leak through any API, even if there are specialized ones in the ...
6
votes
Get account transactions using Substrate API
No blockchain is designed to be able to easily get all transactions for an account, as this is a waste of storage for a normal syncing chain.
Substrate provide the ability to run an Archive node, ...
5
votes
JSON-RPC getBlockHash Request
The JSON-RPC 2.0 parameters doesn't go in the header, they are part of the body. Here is a correctly-formatted body for a getBlockHash query -
{
"id":1,
"jsonrpc":"2.0&...
4
votes
Is that possible to implement bridge to send USDT from statemint to other parachains?
You don't need a bridge at all, Polkadot includes a message transport protocol for its parachains. I'd check out Subscan's XCM explorer to look at examples of asset transfers and how those ...
3
votes
List of assets on Statemint
Using PolkadotJS you can get the list of assets with this script:
const wsProvider = new WsProvider('wss://statemint.api.onfinality.io/public-ws');
const api = await ApiPromise.create({ ...
3
votes
How we can Create Wallet / Generate address in polkadot
It depends on the chain.
Most of the chains are using SR25519.
Check https://github.com/polkascan/py-sr25519-bindings.
Example:
# you need to install py-sr25519-bindings first.
import sr25519
from ...
3
votes
How to query transaction details by using the transaction hash on polkadot by using python
Transaction hashes have a different meaning in Polkadot than in Ethereum.
Ethereum TX hashes uniquely identify a transaction in a Block.
TX hashes in Polkadot are not necessarily unique. They are ...
3
votes
Accepted
How to determine which parameters are required when using substrate.query() to query a storage_function from polkascan's py-substrate-interface?
Update: The storage_function.get_param_info() helper function is introduced, see: https://github.com/polkascan/py-substrate-interface#type-information-about-how-to-format-parameters
It is indeed a ...
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 ...
3
votes
How to get the token balance(rmrk) by py-substrate?
from substrateinterface import SubstrateInterface
ASSET_ID = 8 # RMRK.app
ACCOUNT = '<<YOUR_ACCOUNT>>'
substrate = SubstrateInterface(url='wss://statemine-rpc.polkadot.io')
account_info ...
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 ...
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 ...
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 ...
2
votes
How do I best calculate angle differences when crossing the 360 axis? (Python)
I think you are in the wrong Stack Exchange :)
But I don't think it's possible for anyone to answer without knowing the data source, e.g. is it a lateral inertial sensor that senses side-to-side ...
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 ...
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 ...
2
votes
Accepted
How to convert ss58 address to a different parachain in py-substrate-interface
py-substrate-interface provides helper functions for that in the utils.ss58 namespace.
Transforming an address from one chain-id to another can look like this:
from substrateinterface.utils.ss58 ...
2
votes
Why do are some events in a block missing an extrinsic_idx?
Only the events in phase ApplyExtrinsic have an extrinsic index attached.
Everything that runs before is from on_initialize hooks and everything afterwards from on_finalize.
These always run in every ...
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 ...
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 ...
2
votes
Historical Balance of Polkadot Accounts (python substrate)
Instead of getting all the events and adding up balances, you can directly query system.account(AccountId32) for the balance of the account/accounts at a specific block number. You are still required ...
2
votes
Historical Balance of Polkadot Accounts (python substrate)
I agree with ehpeeeye, a very good approach would be to use the system.account storage function or leverage the features an indexer provides. The Substrate-ETL dataset would provide granular ...
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 ...
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 ...
1
vote
Accessing historical data for validators from the API
Take a look into this tool substrate-api-sidecar, it makes easy to interact with blockchain nodes via API queries.
Connect the tool into your local network or into Polkadot creating a .env file with:
...
1
vote
Is that possible to implement bridge to send USDT from statemint to other parachains?
Like Joe is saying, you need to open HRMP channels and then send an XCM.
You can see the actual XCM Joe referenced here:
https://statemine.subscan.io/extrinsic/2978330-2?event=2978330-5
More info ...
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", [])
1
vote
JSON-RPC getBlockHash Request
import json
# pip3 install websocket-client
import websocket
uri = 'wss://rpc.polkadot.io'
ws = websocket.create_connection(uri)
for block_number in range(11627380, 0, -1):
print(block_number)
...
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 = ...
1
vote
How to decode RPC results using Python's Scale library
Is there a specific reason why you manually want to decode raw SCALE-data? Because SCALE is without context, you need the exact type definition of the storage function and even specific runtime where ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
python × 36substrateinterface × 14
polkadot × 9
rpc × 5
polkascan × 4
assethub × 4
assets × 3
kusama × 2
xcm × 2
transactions × 2
account × 2
api × 2
data-analytics × 2
staking × 2
scale-codec × 2
py-substrate-interface × 2
pallet × 1
ink × 1
balances × 1
rust × 1
parachain × 1
storage × 1
polkadot-js × 1
query × 1
karura × 1