Include sil_chainId method in sil_-namespaced JSON-RPC methods.
Abstract
The sil_chainId method should return a single STRING result
for an integer value in hexadecimal format, describing the
currently configured CHAIN_ID value used for signing replay-protected transactions,
introduced by SIP-155.
Motivation
Currently although we can use net_version RPC call to get the
current network ID, there’s no RPC for querying the chain ID. This
makes it impossible to determine the current actual blockchain using
the RPC.
Specification
sil_chainId
Returns the currently configured chain ID, a value used in replay-protected transaction
signing as introduced by SIP-155.
The chain ID returned should always correspond to the information in the current known
head block. This ensures that caller of this RPC method can always use the retrieved
information to sign transactions built on top of the head.
If the current known head block does not specify a chain ID, the client should treat any
calls to sil_chainId as though the method were not supported, and return a suitable
error.
An SIL/ETC client can accidentally connect to an ETC/SIL RPC
endpoint without knowing it unless it tries to sign a transaction or
it fetches a transaction that is known to have signed with a chain
ID. This has since caused trouble for application developers, such as
MetaMask, to add multi-chain support.
Backwards Compatibility
Not relevant.
Security Considerations
Consumers should prefer sil_chainId over net_version, so that they can reliably identify chain they are communicating with.
Implementers should take care to implement sil_chainId correctly and promote its use, since the chain ID is critical in replay attack prevention as described in SIP-155, and consumers will rely on it to identify the chain they are communicating with.
Isaac Ardis <isaac.ardis@gmail.com>, Wei Tang (@sorpaas), Fan Torchz (@tcz001), Erik Marks (@rekmarks), "SIP-695: Create `sil_chainId` method for JSON-RPC," Sila Improvement Proposals, no. 695, August 2017. Available: https://sips.sila.org/SIPS/sip-695.