Getting Started
Json-RPC Relay allows you to use tools based on ethereum's JSON-RPC API to tap into the Hedera ecosystem. This documentation goes through the steps of setting up Arkhia's Json-RPC Relay thorugh popular ethereum based tools as well as direct API calls.
All examples below have been tested and verified using the available Json-Rpc release by Arkhia.
info
You will need:
- Arkhia JSON_RPC_URL
- Arkhia API_KEY
Both the URL and API KEY can be retrieved from the Arkhia Dashboard after you Create a Project.
Don't have an account yet with Arkhia? Signup.
Go to the Services section in project details to get the necessary information
- Web3.js
- Node.js (Axios)
- Curl
import Web3 from 'web3';const HTTP_PROVIDER_URL_MAINNET = '<JSON_RPC_URL>/<YOUR_API_KEY>';const HTTP_PROVIDER_URL_TESTNET = '<JSON_RPC_URL>/<YOUR_API_KEY>';const web3Provider = new Web3(new Web3.providers.HttpProvider(HTTP_PROVIDER_URL_MAINNET), { keepalive: true, headers: [{ name: 'Access-Control-Allow-Origin', value: '*' }], withCredentials: false});const getLiveness = async () => { web3Provider.eth.net.isListening() .then(() => console.log(`-> web3 provider is connected`)) .catch(e => console.log('-> web3 provider error: ' + e));}async function main() { await getLiveness();}
import axios from 'axios';const data = JSON.stringify({ "jsonrpc": "2.0", "method": "net_listening", "params": [], "id": 0});const config = { method: 'post', url: '<JSON_RPC_URL>/<YOUR_API_KEY>', headers: { 'Content-Type': 'application/json'}, data : data};async function main() { await axios(config) .then(function (response) { console.log(response.data)); }); .catch(function (error) { console.log(error); });}
curl --location --request POST '<JSON_RPC_URL>/<YOUR_API_KEY>' \--header 'Content-Type: application/json' \--data-raw '{ "jsonrpc": "2.0", "method": "net_listening", "params": [], "id": 0}'