Comment on page
JSON RPC Server
Learn about the JSON-RPC server to interact with the EVM.
JSON-RPC is a stateless, light-weight remote procedure call (RPC) protocol. Primarily this specification defines several data structures and the rules around their processing. It is transport agnostic in that the concepts can be used within the same process, over sockets, over HTTP, or in many various message passing environments. It uses JSON (RFC 4627) as data format.
JSON-RPC is provided on multiple transports. fxCore supports JSON-RPC over HTTP and WebSocket. Transports must be enabled through command-line flags or through the
app.tomlconfiguration file. For more details see the 
Ethereum JSON-RPC APIs use a name-space system. RPC methods are grouped into several categories depending on their purpose. All method names are composed of the namespace, an underscore, and the actual method name within the namespace. For example, the eth_call method resides in the eth namespace.
At present there are two key datatypes that are passed over JSON: unformatted byte arrays and quantities. Both are passed with a hex encoding, however with different requirements to formatting:
When encoding QUANTITIES (integers, numbers): encode as hex, prefix with
"0x", the most compact representation (slight exception: zero should be represented as
0x41(65 in decimal)
0x400(1024 in decimal)
0x(should always have at least one digit - zero is
0x0400(no leading zeroes allowed)
ff(must be prefixed
When encoding UNFORMATTED DATA (byte arrays, account addresses, hashes, bytecode arrays): encode as hex, prefix with
"0x", two hex digits per byte. Examples:
0xf0f0f(must be even number of digits)
004200(must be prefixed
The following methods have an extra default block parameter:
When requests are made that act on the state of fxCore, the last default block parameter determines the height of the block.
The following options are possible for the
HEX String- an integer block number
String "earliest"for the earliest/genesis block
String "latest"- for the latest mined block
String "pending"- for the pending state/transactions
The curl options below might return a response where the node complains about the content type, this is because the
--dataoption sets the content type to
application/x-www-form-urlencoded. If your node does complain, manually set the header by placing
-H "Content-Type: application/json"at the start of the call.
The examples also do not include the URL/IP & port combination which must be the last argument given to curl e.x.