JSON RPC¶
Description¶
We require that the clients via JSON RPC. A list of available RPC methods are specified separately.
We chose JSON RPC because the protocol is relatively simple and because it interacts well with TypeScript. Ethereum also uses JSON RPC for its client communication. The structure of our RPC methods are based heavily on the structure of Ethereum’s RPC methods to reduce cognitive overhead for client developers.
Data Structures¶
JsonRpcRequest¶
interface JsonRpcRequest {
jsonrpc: '2.0'
method: string
params?: any
id: string | number
}
Description¶
Represents a JSON RPC request.
Fields¶
jsonrpc
-string
: MUST be exactly ‘2.0’.method
-string
: Name of the method to call.params?
-any
: Formatted request parameter object.id
-string | number
: Request identifier.
JsonRpcSuccessResponse¶
interface JsonRpcSuccessResponse {
jsonrpc: '2.0'
result: any
id: string | number
}
Description¶
Represents a successful JSON RPC response.
Fields¶
jsonrpc
-string
: MUST be exactly ‘2.0’.result
-any
: Formatted response to the request.id
-string | number
: Same identifier as the one given during the request.
JsonRpcError¶
interface JsonRpcError {
code: number
message: string
data: any
}
Description¶
Represents information about a JSON RPC error.
Fields¶
code
-number
: Error code ID.message
-string
: Additional short error message.data
-any
: Additional error information.
JsonRpcErrorResponse¶
interface JsonRpcErrorResponse {
jsonrpc: '2.0'
error: JsonRpcError
}
Description¶
Represents a JSON RPC error response to request.
Fields¶
jsonrpc
-string
: MUST be exactly ‘2.0’.error
-JsonRpcError
: RPC error object.