(source https://hackmd.io/@polkadot/jip2 from 2025-04-24)
JIP-2: Node RPC
RPC specification for JAM nodes to ensure JAM tooling which relies on being an RPC client is implementation-agnostic.
Notes
RPCs are evil and should generally not be used: they lead to chronic centralisation and trust-maximisation (just see Ethereum for a great example of this trap).
However, there are not at present any light clients for JAM and the resources needed to run a regular client make the inclusion of a full-client inside of tooling to be unrealistic. We must therefore reluctantly presume that the tool-user has access to a trustworthy full node and can use its RPCs.
As soon as a light-client implementation is viable, the use of RPCs should be phased out immediately in favour of embedded light-clients in the tooling.
RPC specification
Both arguments, results and notification types are passed as an array, which may be null
for certain results (marked as such).
Types:
Hash
: a 32 item array with each item numeric between 0 and 255 inclusive.Slot
: a single numeric item between 0 and inclusive.Blob
: an arbitrary length array each item numeric between 0 and 255 inclusive.ServiceId
: a single numeric item between 0 and inclusive.Parameters
: an object describing the parameters of the JAM chain. See below for more information.
Generally JSON RPC can be used over a variety of media and we don't make any assumptions of this, but it is envisaged that Websockets will be the usual medium, on port 19800.
Subscriptions are handled in the usual way for JSON-RPC. A counterpart unsubscribe...
RPC should be assumed for all subscribe
RPCs; these are ommitted for brevity.
parameters
Returns the parameters of the current node/chain.
- Type: Method
- Arguments: None
- Result:
V1
: The (version 1)Parameters
object. See below.
bestBlock
Returns the header hash and slot of the head of the "best" chain.
- Type: Method
- Arguments: None
- Result:
Hash
: The header hash.Slot
: The slot.
subscribeBestBlock
Subscribe to updates of the head of the "best" chain, as returned by bestBlock
.
- Type: Subscription
- Notification type:
Hash
: The header hash.Slot
: The slot.
finalizedBlock
Returns the header hash and slot of the latest finalized block.
- Type: Method
- Arguments: None
- Result:
Hash
: The header hash.Slot
: The slot.
subscribeFinalizedBlock
Subscribe to updates of the latest finalized block, as returned by finalizedBlock
.
- Type: Subscription
- Notification type:
Hash
: The header hash.Slot
: The slot.
parent
Returns the header hash and slot of the parent of the block with the given header hash, or null
if this is not known.
- Type: Method
- Arguments:
Hash
: The hash of a child's header.
- Result: Either
null
or:Hash
: The parent's header hash.Slot
: The slot.
stateRoot
Returns the posterior state root of the block with the given header hash, or null
if this is not known.
- Type: Method
- Arguments:
Hash
: The header hash.
- Result: Either
null
or:Hash
: state_root