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,757
8 votes

How to curl custom RPC methods?

You can list all RPC methods like this with cURL and jq: curl -sS -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "...
Oliver Tale-Yazdi's user avatar
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
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,131
4 votes
Accepted

Show custom RPCs/RuntimeAPIs in PolkadotJS UI

I don't think the hosted Polkadot JS UI supports Custom RPCs. You need to follow the instructions for defining custom RPCs when initializing your own Polkadot JS instance as documented here Custom ...
Shawn Tabrizi's user avatar
  • 16.1k
4 votes
Accepted

runtime custom rpc is not taking "at" params as optional

I believe there is an issue where the JS API only expects the optional at param as the very last one - basically the de-facto standard order of RPC params in Substrate itself. So basically the form ...
Jaco's user avatar
  • 5,865
3 votes
Accepted

Testing Custom RPC with a Mock Runtime API

tldr: used the sp_api::mock_impl_runtime_apis! macro to mock the implementation. Example is in this PR along with a lot of other changes: https://github.com/LibertyDSNP/frequency/pull/490 See pallets/...
Wil W's user avatar
  • 433
3 votes
Accepted

Similar eth_call for substrate

There is actually. There is a JSONRPC endpoint named state_call. It works in a similar way to eth_call. You can see the definition here.
pepyakin's user avatar
  • 2,184
3 votes
Accepted

Does RuntimeApis storage accesses counts towards PoV when called from RPC and not any extrinisc?

The storage proof (which is part of the Pov) is only collected while building a block. Each storage read that happens in this process is going into the storage proof. When you are doing RPC calls, ...
bkchr's user avatar
  • 11.6k
3 votes

Does RuntimeApis storage accesses counts towards PoV when called from RPC and not any extrinisc?

The PoV is given to the validator for it to be able to execute the state transition function and calculate the new state root (new state). This is to verify the collators have done their work ...
Daan van der Plas's user avatar
2 votes

How to decorate RPC correctly?

Not sure but maybe this will help you ? In mangata this is how we generate types and also RPC methods. Mangata types
Michal Danco's user avatar
2 votes

How to decorate RPC correctly?

Names, which are shown in the rpc.methods, are not related to chain name. So, you change your chain name won't affect those names. These names will only be affected by the annotations on the rpc ...
ironman_ch_parami's user avatar
2 votes

How to make an RPC call from a working custom RPC, decorate types and display info successfully?

Seems like it's an issue with the runtime, not in front-end. //rpc/src/lib.rs fn list_members( &self, supersig_account: AccountId, at: Option<<Block as BlockT>::Hash>, ) -&...
cuteolaf's user avatar
  • 103
2 votes
Accepted

How can I change --rpc-max-connections on already running substrate-based node?

To the best of my knowledge, this can only be modified during startup. At present, this flag does not support dynamic updates.
AurevoirXavier's user avatar
  • 10.7k
1 vote

How to create custom URL for my RPC node?

By proxying it with an ssl enabled proxying webserver, see this question for tips
stakeworld's user avatar
1 vote

A blockchain to read events from another blockchain

With the help of XCM you can do this. Implementing cross-chain communication, such as through the XCM protocol, can be challenging due to the lack of comprehensive documentation. However, you can draw ...
Wakar Seraj Khan's user avatar
1 vote

Custom RPC vs. runtime API

I would always prefer to add a Runtime API over a custom RPC call. Runtime API call information is included in the metadata from V15 (which was recently stabilised), which means that tools (like subxt)...
jsdw's user avatar
  • 1,335
1 vote

Error on custom rpc in new version

New example code is present in transaction-payment rpc that uses jsonrpsee https://github.com/paritytech/substrate/blob/master/frame/transaction-payment/rpc/src/lib.rs impl<C, Block, AccountId> ...
Amiya Behera's user avatar
1 vote

Property X does not exist on type DecoratedRpc

It seems that you require this update from https://github.com/paritytech/substrate/pull/14481. Without it, the custom RPC metadata will not be included in the runtime metadata.
AurevoirXavier's user avatar
  • 10.7k
1 vote

How to send data to custom network?

In Substrate you have the pallet identity: Enables a federated naming system that allows multiple registrars to be added from a specified origin. Registrars can set a fee to provide identity-...
Alex Bean's user avatar
  • 5,757
1 vote

polkadot js RPC can't get u128

please try using .toBigInt() mentioned here in the Polkadot.js API docs
Luke Schoen's user avatar
  • 2,346
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,757
1 vote

Show custom RPCs/RuntimeAPIs in PolkadotJS UI

In order to have your RPC methods to show up, you would need to decorate the types as explained in Shawn's answer, which then need to be added to ./packages/src/api/typesBundle.ts. I am sure there is ...
Ramsey - Decentration's user avatar
1 vote
Accepted

Panic when Using Rayon with runtime_api in a custom RPC

The impl_runtime_apis! macro added some invalid unsafe trait implementations of Sync and Send. These are going to be removed by this pr. Creating the runtime_api would be the correct way, as you ...
bkchr's user avatar
  • 11.6k
1 vote

Calculate fee for a given transaction

Yes, take a look at this How-to-guide in the Substrate website to see how to do it with the Transaction Payment Pallet. Then you can apply this code to your pallet and create the custom RPC, I leave ...
Alex Bean's user avatar
  • 5,757
1 vote
Accepted

How to call a contract using a custom RPC?

Ok, this problem was completely on me. I censored the contract address, so it is impossible to know, but I put in the hash for the contract and not the actual address. Changing 'address' to the actual ...
rajohs's user avatar
  • 491
1 vote
Accepted

Custom RPC parameters

After a few attempts, the only way to make it work was to supply an array of bytes but using ASCII encoding. Example to query item with id '1234': ~ % curl -H "Content-Type: application/json"...
andresvsm's user avatar
  • 1,114
1 vote

Custom RPC parameters

I had the same issue and it answered here. You need to add one more param for Option<BlockHash> I believe you can try this, curl -H "Content-Type: application/json" -d '{"id":...
Burak's user avatar
  • 903
1 vote
Accepted

Releasing custom RPC implementation on only a single testnet runtime

you can just define some empty/dummy impl of the rpc interface, e.g beefy pallet is enabled in rococo but not yet in polkadot or you can define particular rpc collections for each runtime
Ron's user avatar
  • 608

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