3

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't, I am willing to do that if someone is willing to help me to understand how to setup.

If there are any more information on how to setup RPC node, and back to Polkadot.JS. please don't hesitate to contact me and help me with me. Much appreciate.

1
  • Hi @stken99, welcome to the community! You may get a better response limiting your post to one question. If you have multiple questions, consider creating multiple posts.
    – Bruno
    Commented Aug 4, 2022 at 11:21

1 Answer 1

1

You can follow this tutorial

https://github.com/CocDap/VBI-Octopus-2/tree/assignment-3

Step by step for RPC configuration:

  1. Declare your runtime api in your specific pallet: https://github.com/CocDap/VBI-Octopus-2/blob/assignment-3/pallets/template/rpc/runtime-api/src/lib.rs#L7

  2. Declare your rpc method and implement runtime api trait https://github.com/CocDap/VBI-Octopus-2/blob/assignment-3/pallets/template/rpc/src/lib.rs#L37

  3. Declare helper function in your pallet: https://github.com/CocDap/VBI-Octopus-2/blob/assignment-3/pallets/template/src/lib.rs#L211

  4. Define your runtime api in runtime/src/lib.rs: https://github.com/CocDap/VBI-Octopus-2/blob/assignment-3/runtime/src/lib.rs#L441

  5. Add your custom rpc in node/src/rpc.rs: https://github.com/CocDap/VBI-Octopus-2/blob/assignment-3/node/src/rpc.rs#L36

And how you query value through RPC

curl http://localhost:9933 -H "Content-Type:application/json;charset=utf-8" -d   '{
     "jsonrpc":"2.0",
      "id":1,
      "method":"<your rpc method",
      "params": []
    }'

More materials from Substrate:

https://github.com/paritytech/substrate/tree/master/frame/transaction-payment/rpc

https://substrate.recipes/custom-rpc.html ( This is old version, But good info for you)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.