Skip to main content

Ronin JSON-RPC API reference

Overview

This section contains a collection of the Ronin JSON-RPC API methods, which you can use to interact with Ronin nodes programmatically.

Here are some of the features provided by the API:

  • Querying blocks, transactions, balances
  • Querying smart contracts
  • Sending transactions, estimating gas

Authentication

This API requires an API key for authentication. To retrieve your API key, go to Developer Console > your app > Information > KEY. For more information, see Get your API key.

Authorization

You need additional permission to use the following RPC services:

  • Ronin Archive Node
  • Ronin WebSockets

To request permission, go to Developer Console > your app > App Permission > Ronin Archive Node > Request Access. Same steps apply for WebSockets. For more information, see Connect to an archive node and Connect over WebSocket.

Use with Web3.js and ethers.js

Web3.js
const options = {
headers: [
{ name: 'x-api-key', value: 'xxxxxx' },
],
};

const web3Provider = new Web3.providers.HttpProvider('https://api-gateway.skymavis.com/rpc', options);
const web3 = new Web3(web3Provider);

console.log('Latest block number:', await web3.eth.getBlockNumber());
Ethers.js
const connection = {
url: 'https://api-gateway.skymavis.com/rpc',
headers: {
'x-api-key': 'xxxxx'
}
};

const provider = new ethers.providers.JsonRpcProvider(connection);

console.log('Latest block number:', await provider.getBlockNumber());

Another way is to add your API key in the request header:

Web3.js
const apiKey = 'YOUR_API_KEY';
const web3Provider = new Web3.providers.HttpProvider('https://api-gateway.skymavis.com/rpc?apikey=' + apiKey);
ethers.js
const apiKey = 'YOUR_API_KEY';
const provider = new ethers.providers.JsonRpcProvider('https://api-gateway.skymavis.com/rpc?apikey=' + apiKey);
cURL
curl --location --request POST 'https://api-gateway.skymavis.com/rpc?apikey=YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [
],
"id": 1
}'

Status codes

The following table includes common error codes and their meaning.

CodeMessageDescription
-32700Parse errorInvalid JSON
-32600Invalid requestJSON is not a valid request object
-32601Method not foundMethod does not exist
-32602Invalid paramsInvalid method parameters
-32603Internal errorInternal JSON-RPC error

Error object format

All errors returned by the Ronin JSON-RPC API return an object with this structure:

{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32602,
"message": "too many arguments, want at most 0"
}
}

See also

Was this helpful?
Happy React is loading...