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 BalancesApiServer to the struct Balances.

I expect that macro implements into_rpc behind the scenes. However, compiler says no method named into_rpc found for struct Balances in the current scope. enter image description here

If I expand macro, I can see into_rpc trait is generated, enter image description here

How can I implement in on BalancesApi struct which will be used in create_full function? Some additional procedure is required?

Just an additional info, This is my working branch https://github.com/AstarNetwork/swanky-node/pull/67

  • This might not be a good questions, not being able to what could be an issue so far.
    – Shunsuke
    Commented May 14, 2023 at 12:01

2 Answers 2


The implementation looks good, but it seems like you are missing some import of the pallet-balances-rpc because there is a warning saying BalancesApiServer is unused.

You can try to follow this guide on StackExchange: How to add custom RPCs?, which is a step by step guide about how to create a custom RPC in the pallet template.

  • Thank you for your comment, I thought BalancesApiServer is unused because Balances struct is not implementing into_rpc method. I think I followed the how to guide (Thank you for the detailed contents!), but didn't find out what is the issue my implementation has. The wired thing I found after posting this is if I remove a generic P which is for TransactionPool from the entire code base, then it compiles. pallet-balances-rpc package itself compiles, so that makes it difficult for me to know why into_rpc not implemented.
    – Shunsuke
    Commented May 16, 2023 at 2:44
  • Now it compiles, but why into_rpc was not implemented is unknown. It make sense if I get some trait bound error, but error about "not implemented" is not something I understand.
    – Shunsuke
    Commented May 17, 2023 at 10:17

The trait bounds are most likely not satisfied for the into_rpc impl, that's why your code won't compile.

You probably need additional trait bounds in your function for the params/return types satisfy Send + Sync + serde::de::DeserializeOwned.

Depending on context you may need serde::se::Serialize as well...

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.