Skip to main content
7 votes

How to decode extrinsic at json-RPC call's data(byte code)

You can use @polkadot-js and do something like this: const wsProvider = new WsProvider('wss://rpc.polkadot.io'); const api = await ApiPromise.create({ provider: wsProvider }); const exampleBlockNumber ...
Bruno's user avatar
  • 8,365
7 votes
Accepted

How to decode extrinsic at json-RPC call's data(byte code)

As mentioned in the wiki page https://wiki.polkadot.network/docs/build-node-interaction, some return values (like extrinsics) are SCALE encoded and you need to decode them by using the metadata. You ...
dominique's user avatar
  • 1,683
6 votes
Accepted

Can the metadata of Polkadot change?

From the Substrate docs Since the runtime of a Substrate blockchain is an evolving part of the blockchain's state, blockchain metadata is stored on a per-block basis. Be aware that querying the ...
olanod's user avatar
  • 531
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&...
Ben Travers's user avatar
5 votes
Accepted

Can't get balance of ALICE account from RPC via curl

The substrate-node-template allows you to query the system.account storage item, see screenshot The corresponding command is curl -H "Content-Type: application/json" -d '{"id":1, &...
Lana I's user avatar
  • 369
4 votes
Accepted

What is the difference between Metadata and FRAME-Metadata?

The metadata provides essential information regarding the substrate blockchain you are connecting to. It is unique to that chain's runtime. The chain's runtime metadata includes information such as ...
Bruno's user avatar
  • 8,365
4 votes

polkadot js RPC can't get u128

Given that one of the fields in one of the many structs is a u128 you will need to sanitize the values yourself. I would suggest iterating through each value (you may also do this with recursion as we ...
Tarik Gul's user avatar
  • 1,116
3 votes

Get request error using polkadotjs

To understand the error and get a nice message from this error when you only have the index and error, we have to take a look into the code of Substrate. The index number is the index of the pallet in ...
Alex Bean's user avatar
  • 5,722
3 votes
Accepted

Rpc payment_queryFeeInfo fails on Westend 9310

Generally (this is not the first time this happens), this indicates a mismatch between the node and runtime versions, i.e. the RPC node calls into the runtime and then cannot decode the response. ...
Jaco's user avatar
  • 5,865
3 votes

How to solve 'Invalid transaction version'?

For the sake of answering this question (though I have replied to you elsewhere already on this topic); The transaction format is not just a simple SCALE encoding of some details. In rust pseudocode, ...
jsdw's user avatar
  • 1,335
3 votes

Intermitent errors with jsonrpsee: WS error: i/o error: Transport endpoint is not connected (os error 107); terminate connection 1056

It depends on your usecase and the load on your RPC node. The default number of connections is 100 but it is configurable via the CLI flag --ws-max-connections. If you reach the maximum number of ...
Niklas Adolfsson's user avatar
3 votes
Accepted

How to associate stash accounts with host via RPC/JS/shell

Where are you getting this list of candidate validators from? The hasKey query is for checking if a node contains a specific session key. That is, you would not pass an account ID or address to it. I ...
joepetrowski's user avatar
  • 2,955
3 votes
Accepted

How do I include a new rpc that uses a NetworkWorker in the node-template?

To add a new RPC to the Substrate Node Template, you should look at the rpc.rs file included with it that contains an example and docs for adding a new RPC: /node/src/rpc.rs /// Instantiate all full ...
Shawn Tabrizi's user avatar
  • 16k
3 votes

Decode extrinsic on substrate side

Yes, all the information you need to decode those extrinsic blobs can be found using the Runtime Metadata. The first two bytes of any extrinsic will tell you which pallet and call is being made: vv ...
Shawn Tabrizi's user avatar
  • 16k
3 votes
Accepted

Can I make a frontier node only accept json-rpc read methods?

If you want to do it inside the node, you will need to override some of frontiers RPC handlers. For example, you can see the EthApi implementation here:https://github.com/paritytech/frontier/blob/...
JoshOrndorff's user avatar
  • 1,191
3 votes
Accepted

How to get StorageKey associated with an address?

You can also use the apps UI to create keys, generally if these are single items this is a quick approach. In the apps UI via the storage page, you can see the encoded keys based on the input ...
Jaco's user avatar
  • 5,865
2 votes

How to get StorageKey associated with an address?

Great question! If you have a prefix of a storage key that you are looking for, you can specify in the first argument like so: Note that if you specify 0x you will get all the keys! If you want to ...
Bruno's user avatar
  • 8,365
2 votes

How to associate stash accounts with host via RPC/JS/shell

working JS code (thank you @joepetrowski) var validatorAddress = ''; // add your address here var keys = await api.query.session.nextKeys(validatorAddress); var keysJson = JSON.parse(JSON.stringify(...
Matthias Hutter's user avatar
2 votes
Accepted

How to call chain_getBlock with jsonrpsee?

As the error said. The result is a map. let rpc_response: Result<Option<serde_json::Value>, _> = client.request("chain_getBlock", params).await;
AurevoirXavier's user avatar
  • 10.4k
1 vote

Why the two ways to get blockhash is not same?

Maybe it's because your chain is producing blocks now. I think you can get the same result by specifying the block number. This RPC is always get the latest block if you didn't specify the block ...
AurevoirXavier's user avatar
  • 10.4k
1 vote

Retriving the transaction details of a mapping

Not directly. If you want to know in which block the storage changed you would have to scan the Blockchain to try to find the extrinsic that make this storage change. You can do that using for example ...
Alex Bean's user avatar
  • 5,722
1 vote

Custom RPC sized array parameters

[u8; 32] is basically an array of u8. Try directly with the array you have: const message = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, ...
Alex Bean's user avatar
  • 5,722
1 vote
Accepted

Is there a JSON-RPC method similar to `eth_getLogs`?

I believe you'll need to iterate over blocks to query events (see this answer for tips), or use an indexer (look here for an overview of available solutions).
Adam Wierzbicki's user avatar
1 vote

Get request error using polkadotjs

I receive a the same error when running similar code with my own abi JSON. The error decodes to contracts.OutOfGas, which is from the substrate contracts pallet. Note 0x02 probably corresponds to the ...
forgetso's user avatar
  • 1,502
1 vote
Accepted

why node could be started even though i passed both --validator and --rpc-port?

The flags it is referring to are --ws-external and --rpc-external. If you try to run your node with these flags and --validator it will throw an error: Input("--rpc-external and --ws-external ...
Daan van der Plas's user avatar
1 vote

About Polkadot's API List

I'm not aware of another list. However, the documentation of polkadot js covers such API's which you can use to experiment with the substrate node template (e.g. cookbook/examples). Try to obtain the ...
Daan van der Plas's user avatar
1 vote

Why is there no finalization in the substrate-contracts-node?

The consensus algorithm is manual-seal which doesn't contain GRANDPA. Manual seal makes development more convenient since blocks are only authored immediately at every transaction. However, since ...
Daan van der Plas's user avatar
1 vote

@polkadot/api suppress output messages

You should be able to trap the provider and api errors, and then do nothing with them... const provider = new WsProvider('wss://rpc.polkadot.io'); // events: connected, disconnected, error provider.on(...
DerekC's user avatar
  • 205
1 vote

How to query for All Pallets StorageVersions

Getting the pallet version from polkadot-js-api is as simple as: await api.query.system.palletVersion() You can wrap this in a script to give you all of the pallet versions:
kianenigma's user avatar
  • 2,799
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) ...
AurevoirXavier's user avatar
  • 10.4k

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