Astro RPC JSON message format
We used the JSON RPC message format as a guide.
The format of a request and response differ slightly. They both contain an 'id' header, which is the same for the request and the response. It is used to match a response to it's request.
Request
Headers:
- senderAddress: the address of the object sending the request
- id: the unique id of the request
Payload:
- methodName: the name of the RpcMethod that is being called.
- params: an object with named parameters that get passed to the method
{
"senderAddress": <string: Requester Address>",
"id": <integer: callID>,
"payload": {
"method": "<string: Method Name>",
"params": {
"parameterName": "parameterValue"
}
}
}
Response
Headers:
- sender Address: the address of the responder
- id: the id of the request that is being responded to
Payload:
- result: A JSON object representing the result of the executed method
- error: any error that was thrown during the request or execution of the method
{
"senderAddress": <string: responderAddress>,
"id": <Integer callID>,
"payload": {
"result": <primitive or object>,
"error": false
}
}
or in the case of an error:
{
"senderAddress": <string: responderAddress>,
"id": <<Integer callID>,
"payload" {
"result": {},
"error": {
"message": <string: error message>
}
}
}