Hi there! I have a project where I have a middleware between the substrate node and the user who communicate with the node and I want to know what extrinsics users call based on the JSON-RPC calls, but I’m stuck with connecting calls with extrinsics.
How can I identify extrinsics based on the JSON-RPC calls?
I’m not sure I’ve understood 100% your question, so please forgive me if I reply with something that is not what you meant.
If you want to identify calls (not JSON-RPC calls) that are made to the chain, like balances.transferKeepAlive and so on, you need to decode the extrinsic.
All extrinsics are submitted through one of the following RPC methods:
- author_submitExtrinsic
- author_submitAndWatchExtrinsic
- transaction_v1_broadcast
- transactionWatch_v1_submitAndWatch
Here is an example of a payload sent to one of those:
{
"jsonrpc": "2.0",
"method": "author_submitExtrinsic",
"params": ["0x45028400b0665538ae1b64801f5ceaceb5b1d13dde424038e400fef3efa2973706b19922010cc350aa0d8ef20d0ab56bb9ecbe763ea0ec26b54ba6f60d74de4e09e8eccb50872143025ef9c3fae37fb633a1fbf985122a6ea17b85af56afb88354a6613e8a8501140000050300b0665538ae1b64801f5ceaceb5b1d13dde424038e400fef3efa2973706b1992207c0d8eb9508"],
"id": 1
}
The extrinsic is at the params If you decode that extrinsic, you will get the following result:
version + isSigned 4502 84
signer 00 b0665538ae1b64801f5ceaceb5b1d13dde424038e400fef3efa2973706b19922
signature 01 0cc350aa0d8ef20d0ab56bb9ecbe763ea0ec26b54ba6f60d74de4e09e8eccb50872143025ef9c3fae37fb633a1fbf985122a6ea17b85af56afb88354a6613e8a
era 85 01
nonce 14
tip 00
mode 00
callIndex 0503
dest 00 b0665538ae1b64801f5ceaceb5b1d13dde424038e400fef3efa2973706b19922value 07c0d8eb9508
The call starts just after the mode, and you can see it is 05 03 which represents pallet 05, index 03, which would be balances.transferKeepAlive (on Paseo)
So, for your use case, you would need to get all extrinsics and decode them to find out which call they are making.
If that’s not what you meant, let me know.
This is exactly what I was looking for. Many thanks!