Questions tagged [rpc]

Questions relating to custom RPC implementations or using existing RPCs to make calls to a Substrate node.

Filter by
Sorted by
Tagged with
12 votes
1 answer
272 views

PolkadotJS how to properly setup api for custom RPC invocation

I'm playing around with custom RPC endpoints exposed from my substrate node, but I'm encountering an issue when trying to call it with polkadotjs. Initially, my endpoint only accepted a single ...
Tony's user avatar
  • 527
10 votes
2 answers
371 views

Generating an extrinsic call for a custom pallet

I'm trying to generate an extrinsic offline based on this example. It worked, but the signed transaction is different. Call Data As you can see in the output the Call Hash is the same. Signed ...
Amir Boziev's user avatar
9 votes
2 answers
239 views

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

Which api/rpc call and method do I need to use to extract the state of all balances at a certain block? Let's use Polkadot and recent block as an example: https://polkadot.js.org/apps/?rpc=wss%3A%2F%...
Decentration's user avatar
  • 1,356
9 votes
3 answers
190 views

Error adding Custom RPCs for pallet

I've been trying to add some rpc calls available for my node, but an error related to the 'getrandom' module appears (even tho I'm not even using it). I have a very simple pallet that creates and ...
andresvsm's user avatar
  • 1,104
8 votes
1 answer
194 views

Generating a Storage Key when making an RPC request

I'm trying to make an RPC call to a Substrate node, but I can't generate a proper Storage Key. The Module and Method parts are fine, the problem is the Twox64Concat part. The sp_core::twox_64 of value ...
Amir Boziev's user avatar
7 votes
2 answers
82 views

Is it ok to combine RPC node with collator together?

For a parachain is it ok to have RPC and collator in one node? If not why? I'd love to hear some deeper explanation.
Curu's user avatar
  • 93
7 votes
1 answer
102 views

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

Using either a Rust or JavaScript client library I would like to get the amount of DOT that is currently being unbonded on the relay chain. Some staking information is available in the Polkadot JS ...
Rtsne42's user avatar
  • 379
7 votes
1 answer
169 views

Is it possible to query an OCW's Off-chain storage via RPC from an external service?

I'm off-chain indexing some pallet events into my off-chain local storage using an OCW. Now, I want to be able to retrieve this data via RPC from an external service. Is this possible? Does it require ...
Pablo Buitrago's user avatar
6 votes
2 answers
197 views

What's the different between "Extrinsic" and "RPC" methods for pallets?

I notice that for the nicks pallet there is no need to write a custom RPC or configure that, while with the contracts pallet that need seems to be there. It also seems that in the Substrate Front End ...
Darian Foulds's user avatar
5 votes
1 answer
741 views

How to add custom RPCs?

I have the template pallet in the Substrate node template. This pallet template has a function do_something that store a value in the storage. I would like to create an RPC call that queries that ...
Alex Bean's user avatar
  • 5,364
5 votes
1 answer
941 views

Custom RPCs not decorated

I added some custom RPC endpoints to a substrate blockchain, but when I connect to the node with a simple script it prints: API/INIT: RPC methods not decorated: ... The RPCs work, but don't show up ...
weichweich's user avatar
5 votes
1 answer
101 views

How to turn off certain RPCs?

According to substrate rpc docs we shouldn't be exposing some RPCs as they are deemed dangerous. How does one go about turning them off? Currently if I query my node, I have all those RPCs running ...
Purple_Turtle's user avatar
5 votes
2 answers
195 views

Decode extrinsic on substrate side

hello is there a way to decode this kind of extrinsic on substrate side without polkadotJs : extrinsics: [0402000b935b2a697f01, ...
cibou's user avatar
  • 131
5 votes
1 answer
104 views

Removing randomness-collective-flip pallet from runtime

We recently tried to remove pallet-randomness-collective-flip from our runtime. This pallet has been in our runtime since it was created as it was included in the template-node-runtime, but we never ...
AlastairHolmes's user avatar
5 votes
1 answer
107 views

How to implement `into_rpc` method in jsonrpsee's rpc macro

I'm trying to add custom RPC to Substrate node template. As explained in the jsonrpsee's proc_macro doc here, I define BalancesApi trait where #[rpc(server)] attribute added, and implement ...
Shunsuke's user avatar
  • 432
5 votes
0 answers
107 views

How to extend a `custom RPC` service to query the `off-chain` storage? [closed]

There are many docs/tutorials explaining how to extend the node's RPC service with a Custom RPC to query the Runtime storage. What I could not figure it out yet, is how to do the same but to query the ...
Pablo Buitrago's user avatar
4 votes
1 answer
236 views

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

Could Polkadot experts execute the code below and advise me on the questions, please? You just need to replace the code by your own Westend accounts and nonce. import { construct, getRegistry, ...
drhanlondon's user avatar
4 votes
2 answers
220 views

How to decorate RPC correctly?

The rpc methods (showing in rpc_methods), are still not showing in their own area, after (attempting to) decorate the rpc. I have custom rpc on a substrate template. Here are the rpc_methods: I have ...
Decentration's user avatar
  • 1,356
4 votes
1 answer
434 views

Decoding events with Rust

If I make a request to get events in a particular block using web UI, I get a nice human-readable response: I've made an RPC call to get the same data { "id": 1, "jsonrpc":...
Amir Boziev's user avatar
4 votes
1 answer
284 views

Implementation of runtime api RPC

I am trying to implement custom rpc using the tutorial : https://substrate.recipes/custom-rpc.html, I successfully implemented silly rpc but getting error for runtime api rpc. Here are my code: ...
Amiya Behera's user avatar
4 votes
1 answer
127 views

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

I understand that there are two main Rust client libraries for Substrate: subxt substrate-api-client I've checked out the examples for both libraries and it seems to me that they are mostly the same....
Rtsne42's user avatar
  • 379
4 votes
2 answers
161 views

Read a value from offchain storage of a node

I want to read a single value from OffchainStorage of a live substrate node. Is it possible? Assume I can not use localStorageGet rpc request because it is an unsafe rpc.
Matt Duncan's user avatar
4 votes
1 answer
362 views

Rpc payment_queryFeeInfo fails on Westend 9310

After the latest upgrade of Westend runtime to version 9310 the RPC call payment_queryFeeInfo fails with the following error message: {"jsonrpc":"2.0","error":{"code&...
Valentun's user avatar
  • 220
4 votes
2 answers
118 views

RPC full type specification from metadata

Since metadata v14 and scale-info were introduced, the runtime fully specifies all runtime interfaces and types. On the RPC side however the rpc_methods only returns the list of methods exposed, ...
Xiu Hung's user avatar
  • 497
4 votes
1 answer
87 views

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

The node-template says its service.rs is a specialisation of that on the substrate master branch. Hence, it's sort of hard to relate the two. Nonetheless, I'd like to expose an RPC endpoint that's ...
islami00's user avatar
  • 561
4 votes
2 answers
145 views

How to update the SS58Prefix for a running node?

If I have started running a Substrate node but the ss58Format value in the chain specification .json file that is generated from using the build-spec command is not 42, how do I update the chain so ...
linus NG's user avatar
  • 311
3 votes
2 answers
273 views

Getting extrinsic data with the transaction hash

I've successfully submitted the extrinsic RPC call and got a JSON response { "jsonrpc": "2.0", "result": "...
Amir Boziev's user avatar
3 votes
1 answer
106 views

How do I upgrade my node's RPC?

Following along the Substrate's Forkless Upgrades guide. I can upgrade the runtime but I can't figure it out how to upgrade my pallet's RPC. I have commented the below code for testing purposes and ...
Burak's user avatar
  • 893
3 votes
2 answers
173 views

polkadot js RPC can't get u128

i have an rpc call that returns an array of structs with multiple fields, one of which is balance of an asset for a user, balance type is u128. when the number is large i get this error createType(...
cocokick's user avatar
  • 165
3 votes
1 answer
206 views

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

I am trying to add the pallet-contracts-rpc dependency but keep getting this error. ''' error: no matching package named pallet-contracts-rpc found location searched: https://github.com/paritytech/...
Kaioh33's user avatar
  • 63
3 votes
1 answer
70 views

How to query the max extrinsic weight over rpc?

How do i query over rpc the maximum weight for normal extrinsics as defined in frame_system here: https://github.com/paritytech/substrate/blob/master/frame/system/src/limits.rs#L99-L122
Web3 Philosopher's user avatar
3 votes
1 answer
46 views

How to expose `engine_createBlock` manual-seal RPC? [closed]

Right now when I run: curl -H "Content-Type: application/json" -d '{"id":"1", "jsonrpc":"2.0", "method": "rpc_methods", "...
basketball9's user avatar
3 votes
1 answer
148 views

How to encode an extrinsic for RPC from a web client?

I need to programmatically pack an extrinsic for an RPC, I believe I'm looking for the following front-end functionality: extract relevant indices from the Metadata fill the extrinsic parameters ...
Yury Yukhananov's user avatar
3 votes
1 answer
58 views

How to build the browser extension with substrate?

Can we make browser extension with substrate and yes and how ? can anyone please provide the resource to read about it ?
Deepak Chaudhary's user avatar
3 votes
1 answer
47 views

Duplicate Lang Error When Adding Custom RPC

I am trying to add a custom rpc in Substrate, but I ran into a problem. I have done all steps in this article: Add custom RPC to the node and my code is here: https://github.com/dortajkianoush/...
Mr Coder's user avatar
  • 873
3 votes
1 answer
73 views

RPC deployment Guideline

I have a question in regard to RPC node for Polkadot or Substrate. RPC node configuration - I don't see too many information about this. Is there public information on how to setup a RPC, if there isn'...
stken99's user avatar
  • 31
3 votes
1 answer
109 views

u128 is not supported on jsonrpc

u128 is not supported on rpc. So I am trying to use NumberOrHex How to setup and RPC call that accepts a u128 input? Here is my code for runtime api: #![cfg_attr(not(feature = "std"), no_std)...
Amiya Behera's user avatar
3 votes
1 answer
197 views

Can't request to my Custom RPC with an Enum

I'm trying to create a custom RPC for my pallet. I've followed Substrate Recipes (I know it's outdated but helped a lot) and pallet_transaction for Runtime API and RPC. My first RPC, profile_getSum, ...
Burak's user avatar
  • 893
3 votes
1 answer
59 views

Custom RPC vs. runtime API

As a Substrate builder, I don't see any reason of still implementing custom RPCs as runtime API seems superior to me. So I was wondering about any arguments for still adding custom RPCs to the client. ...
0x5hmoo's user avatar
  • 167
3 votes
1 answer
33 views

Off chain worker for https:// request

I have a simple question if i use off chain workers to get calls to https://somecoinexchange/ to get data for some calculation, what will be the gas usage. I was presuming that since no chain work is ...
Nöörah Smith's user avatar
3 votes
1 answer
64 views

When will I stop receiving TransactionStatus updates for a transaction submitted via author_submitAndWatchExtrinsic?

If I submit a transaction via "author_submitAndWatchExtrinsic", I start getting back TransactionStatus updates, which look like one of these: pub enum TransactionStatus<Hash, BlockHash>...
jsdw's user avatar
  • 1,284
3 votes
1 answer
217 views

Dev Substrate Node at Capacity for WS Connections, how to flush?

I'm running a node in dev mode: ./substrate/target/release/substrate --dev --tmp --ws-external My client connection code: provider = new WsProvider(wsProvider) api = await new ApiPromise({ provider })....
Matthew Darnell's user avatar
2 votes
2 answers
113 views

Finding about native token of a parachain

Is there a way to query whether a chain has a native token and what it is? For instance can I query Moonbeam, to find that it's native token is GLMR(Glimmer). Similarly for the rest of the parachains.
Pranay's user avatar
  • 141
2 votes
3 answers
139 views

JSON-RPC getBlockHash Request

I am trying to request a block hash for a specific block using the Polkadot JSON-RPC but no matter how I construct the request (with Python), it always returns the latest block and not the one I want. ...
Teodor's user avatar
  • 21
2 votes
2 answers
238 views

How to get StorageKey associated with an address?

StorageKey keyword mentioned in the RPC substrate docs and polkadotJS RPC API docs https://polkadot.js.org/docs/substrate/rpc#getkeyskey-storagekey-at-blockhash-vecstoragekey How to get this ...
muddlebee's user avatar
2 votes
1 answer
412 views

What is an RPC node?

What is an RPC node and how to build one as a developer. Also, are there any resources available?
lewis's user avatar
  • 21
2 votes
1 answer
50 views

Calculate total staked & rewarded for validation per era/block

Is there an elegant way to get the total amount staked & rewarded for each era/block? Right now I get a list of staking.Bonded data from Subscan: { "code": 0, "message": &...
Begley Brothers Inc's user avatar
2 votes
2 answers
122 views

Help needed with payloads and extrinsics

I know that the payload and extrinsics are dynamic, and even different between parachains/base chains(kusama,polkadot,rococo,westend). But I am struggling to find good documentation on how these ...
Peso's user avatar
  • 21
2 votes
1 answer
201 views

Sometimes Polkadot JS won't connect to the local node, unless I enable rpc-cors all

I am using the polkadot js appimage and sometimes while connecting to my node, I see this : Blocked connection to WebSockets server from untrusted origin: Some("file://"). I've tried running ...
Purple_Turtle's user avatar
2 votes
1 answer
74 views

How do you query a list of all previous block hashes from a substrate based chain?

I can see how to do so from the subscan api but I am interested in understanding how to query this data from the chain itself. Ie via a storage function or by another means
olliecorbs's user avatar