Skip to main content
14 votes
Accepted

How to add custom RPCs?

Remote Procedure Calls, or RPCs, are a way for an external program—for example, a browser or front-end application—to communicate with a Substrate node. Substrate comes with several default RPCs and ...
Alex Bean's user avatar
  • 5,722
10 votes

Generating an extrinsic call for a custom pallet

The problem is the way you encode the call data. Since your call_data in main is a vector, when you encode it into the temporary byte vector in encode_extrinsic, SCALE first appends the length of the ...
kukabi's user avatar
  • 543
10 votes

How can we get a snapshot of all balances at a certain block?

First, set up a Polkadot JS API connection for the block you want: const provider = new WsProvider(endpoint); const api = await ApiPromise.create({ provider }); const blockHash = await api.rpc.chain....
Shawn Tabrizi's user avatar
  • 16k
8 votes
Accepted

How do I upgrade my node's RPC?

The environment has 2 parts: the on-chain runtime (WASM) and then the node that executes the actual runtime. Effectively the runtime deals with everything that happens on-chain. The node deals with ...
Jaco's user avatar
  • 5,865
8 votes
Accepted

Custom RPCs not decorated

The only information that is exposed to APIs are the names of the RPCs, this excludes - the actual description of the method (optional, but useful in some case) the actual input parameters and their ...
Jaco's user avatar
  • 5,865
7 votes
Accepted

Generating a Storage Key when making an RPC request

I believe all the confusion here is related to the encoding of byte vectors. Vectors in SCALE are encoded with a length prefix represented with a compact number. A collection of same-typed values is ...
Shawn Tabrizi's user avatar
  • 16k
7 votes
Accepted

How to turn off certain RPCs?

While these RPCs are available, they are not callable if you "disable" them. If you run with --rpc-methods Safe all the rpc methods that are seen as "unsafe" will return an error ...
bkchr's user avatar
  • 11.3k
7 votes
Accepted

PolkadotJS how to properly setup api for custom RPC invocation

In general, issues like this are due to incorrectly encoding Vec in SCALE. All Vecs are prepended with their length (section Vectors (lists, series, sets)). A collection of same-typed values is ...
Shawn Tabrizi's user avatar
  • 16k
7 votes
Accepted

How to send transactions using RPC?

To send the transaction look at the author_submitExtrinsic and author_submitAndWatchExtrinsic, the latter when using subscriptions and wanting to have access to the processing status. As to the format,...
Jaco's user avatar
  • 5,865
7 votes
Accepted

Is it possible to submit an extrinsic using rpc?

Yes, with the RPC request author_submitExtrinsic https://polkadot.js.org/docs/substrate/rpc/#submitextrinsicextrinsic-extrinsic-hash You have to get the balance_transfer extrinsic signed and you can ...
Alex Bean's user avatar
  • 5,722
6 votes

Can't connect to pokadot-js UI from my VPS blockchain

Turning a non-secure endpoint into a secure endpoint cannot be done simply by adding wss:// in-front. The wss:// assumes that there is a secure connection with a certificate. In this case if you check ...
Jaco's user avatar
  • 5,865
6 votes

Getting extrinsic data with the transaction hash

I'm facing the same kind of question I think. The problem is that it doesn't really matter if your extrinsic is executed correctly or not, if the transaction submitted is correct (the structure and ...
andresvsm's user avatar
  • 1,114
6 votes
Accepted

Is it ok to combine RPC node with collator together?

It depends of who can access the RPC part but mostly it is not a good idea if other people than you can access it. The role of the collator is to produce blocks, at a very specific moment (when ...
Crystalin's user avatar
  • 790
6 votes

fork-off-substrate dying at 37% with rpc max size disconnect

It looks like that fork-off-substrate was not maintained actively. You could try the subalfred. It uses WS/Rust/Async. So, it's really fast. For me, it scrapes 200k pairs in 10 seconds (in localhost). ...
AurevoirXavier's user avatar
  • 10.4k
6 votes
Accepted

Substrate call raw transaction

05000046ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a30 is an encoded call, but it is not an encoded extrinsic. So you won't be able to submit that into the pool, the format is ...
Jaco's user avatar
  • 5,865
6 votes

Sign a transaction offline for Westend testnet and verification of the transaction

For context all the information to answer this question is in this github issue: https://github.com/paritytech/txwrapper-core/issues/296 Given the address you are using to conduct the transaction, ...
Tarik Gul's user avatar
  • 1,116
5 votes

How to map out transaction history between different WebSocket endpoints?

Since this was tagged polkadot-js-api I will give you the JS API perspective on this. The JS API basically only wraps what the Node & runtime exposes. This means - For the Node, all the RPC ...
Jaco's user avatar
  • 5,865
5 votes

How to programmatically get current unbonding information on the Polkadot relay chain?

Here's an example of how I managed to get this information using the @polkadot JavaScript libraries. Import the Polkadot JS libraries yarn add @polkadot/api @polkadot/util var { ApiPromise, ...
Rtsne42's user avatar
  • 379
5 votes

Getting extrinsic data with the transaction hash

The Substrate author_ RPC namespace has 2 submission mechanisms - author_submitExtrinsic - this only returns the hash, doesn't guarantee inclusion author_submitAndWatchExtrinsic - this is a ...
Jaco's user avatar
  • 5,865
5 votes
Accepted

Extending front-end-template with custom RPC

I believe the template will use the same format as the polkadot-js API since it will pass those through to the API itself, you can find examples here And indeed, if I look at the front-end-template ...
Jaco's user avatar
  • 5,865
5 votes

What is an RPC node?

Remote Procedure Calls, or RPCs, are a way for an external program (eg. polkadot{.js} apps) to make calls to a Substrate node or another way of saying this is that RPC's is a way to allow the outside ...
Bruno's user avatar
  • 8,365
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

Finding about native token of a parachain

You have this information in the chain-spec of the network, if you want to query it, you can use RPC queries for it. Specifically the system_properties RPC call You can query it using CURL: curl -H &...
Alex Bean's user avatar
  • 5,722
5 votes
Accepted

Error: no matching package named 'pallet-contracts-rpc' found

This was removed in #12358, You no longer need to add the RPCs. Have a look at this as an example. Porting Guide The high level contracts API in polkadot.js already uses state_call so upgrading to ...
Nuke's user avatar
  • 1,842
4 votes

Error adding Custom RPCs for pallet

I also noticed that the docs were lacking in explanation on how to add custom rpcs, but then I stumbled on the rust RPC repo by parity. It's referenced at the bottom of the docs on substrate.io that ...
islami00's user avatar
  • 561
4 votes
Accepted

How do `subxt` and `substrate-api-client` libraries differ?

I've not used substrate-api-client yet, but I think one distinguishing feature is autogeneration of code from metadata is something that subxt has put a lot of effort into. substrate-api-client ...
Squirrel's user avatar
  • 3,849
4 votes

Implementation of runtime api RPC

Ya got it, The error was because of file node/src/rpc.rs pub fn create_full<C, P>(deps: FullDeps<C, P>) -> jsonrpc_core::IoHandler<sc_rpc::Metadata> where C: ProvideRuntimeApi&...
Amiya Behera's user avatar
4 votes

Can I get this timestamp through RPC getblock?

If you just use chain_getBlock, one of the extrinsics would be timestamp.set as applied by the block author. This contains the Compact<u64> value of the current timestamp, i.e. milliseconds ...
Jaco's user avatar
  • 5,865
4 votes
Accepted

Decoding events with Rust

There's two ways of decoding events in rust: statically typed and dynamically typed. Statically you can use subxt to decode events from this SCALE encoding - it's done here for example. Basically ...
Squirrel's user avatar
  • 3,849
4 votes
Accepted

How to list all available RPC and extrinsics endpoints of a node?

curl http://127.0.0.1:9933 -X POST -H "Content-Type:application/json" -d '{"jsonrpc":"2.0","method":"rpc_methods","params":[],"id":...
AurevoirXavier's user avatar
  • 10.4k

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