EVM JSON-RPC
Ethereum-Compatible API for Goliath Network
The Goliath EVM Gateway provides a fully Ethereum-compatible JSON-RPC interface, allowing seamless integration with existing Ethereum tools, libraries, and applications. This API enables developers to interact with Goliath using familiar Web3 tooling.
π Overview
Key Features
Full Ethereum Compatibility: Support for all standard Ethereum JSON-RPC methods
High Performance: Sub-second response times with 100,000+ TPS capacity
WebSocket Support: Real-time event subscriptions and updates
Low Latency: Optimized for fast transaction processing
Reliable Infrastructure: 99.99% uptime SLA
Endpoints
Testnet
https://rpc.testnet.goliath.net
wss://rpc.testnet.goliath.net/ws
Mainnet
https://rpc.goliath.net
wss://rpc.goliath.net
π§ Quick Start
Using curl
curl -X POST https://rpc.testnet.goliath.net \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [],
"id": 1
}'Using Web3.js
const Web3 = require('web3');
const web3 = new Web3('https://rpc.testnet.goliath.net');
// Get latest block number
const blockNumber = await web3.eth.getBlockNumber();
console.log('Latest block:', blockNumber);
// Get account balance
const balance = await web3.eth.getBalance('0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb0');
console.log('Balance:', web3.utils.fromWei(balance, 'ether'), 'XCN');Using Ethers.js
const { ethers } = require('ethers');
const provider = new ethers.JsonRpcProvider('https://rpc.testnet.goliath.net');
// Get network info
const network = await provider.getNetwork();
console.log('Connected to:', network.name, 'Chain ID:', network.chainId);
// Get gas price
const gasPrice = await provider.getFeeData();
console.log('Gas price:', ethers.formatUnits(gasPrice.gasPrice, 'gwei'), 'Gwei');π Core Methods
Network Information
eth_chainId
Returns the chain ID of the network.
{
"jsonrpc": "2.0",
"method": "eth_chainId",
"params": [],
"id": 1
}Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x22c5" // 8901 in decimal for testnet
}net_version
Returns the network ID.
{
"jsonrpc": "2.0",
"method": "net_version",
"params": [],
"id": 1
}Block Methods
eth_blockNumber
Returns the number of the most recent block.
{
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [],
"id": 1
}eth_getBlockByNumber
Returns information about a block by block number.
{
"jsonrpc": "2.0",
"method": "eth_getBlockByNumber",
"params": ["latest", true],
"id": 1
}Parameters:
block number: Block number or "latest", "earliest", "pending"boolean: If true, returns full transaction objects
eth_getBlockByHash
Returns information about a block by hash.
{
"jsonrpc": "2.0",
"method": "eth_getBlockByHash",
"params": ["0x...", true],
"id": 1
}Account Methods
eth_getBalance
Returns the balance of an account.
{
"jsonrpc": "2.0",
"method": "eth_getBalance",
"params": ["0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb0", "latest"],
"id": 1
}eth_getTransactionCount
Returns the number of transactions sent from an address (nonce).
{
"jsonrpc": "2.0",
"method": "eth_getTransactionCount",
"params": ["0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb0", "latest"],
"id": 1
}eth_getCode
Returns the code at an address (for smart contracts).
{
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": ["0x...", "latest"],
"id": 1
}Transaction Methods
eth_sendRawTransaction
Submits a signed transaction to the network.
{
"jsonrpc": "2.0",
"method": "eth_sendRawTransaction",
"params": ["0xf86c..."],
"id": 1
}eth_getTransactionByHash
Returns information about a transaction by hash.
{
"jsonrpc": "2.0",
"method": "eth_getTransactionByHash",
"params": ["0x..."],
"id": 1
}eth_getTransactionReceipt
Returns the receipt of a transaction by hash.
{
"jsonrpc": "2.0",
"method": "eth_getTransactionReceipt",
"params": ["0x..."],
"id": 1
}Smart Contract Methods
eth_call
Executes a call without creating a transaction.
{
"jsonrpc": "2.0",
"method": "eth_call",
"params": [
{
"to": "0x...",
"data": "0x..."
},
"latest"
],
"id": 1
}eth_estimateGas
Estimates the gas needed for a transaction.
{
"jsonrpc": "2.0",
"method": "eth_estimateGas",
"params": [
{
"from": "0x...",
"to": "0x...",
"value": "0x...",
"data": "0x..."
}
],
"id": 1
}Gas and Fee Methods
eth_gasPrice
Returns the current gas price in wei.
{
"jsonrpc": "2.0",
"method": "eth_gasPrice",
"params": [],
"id": 1
}eth_maxPriorityFeePerGas
Returns the current max priority fee per gas.
{
"jsonrpc": "2.0",
"method": "eth_maxPriorityFeePerGas",
"params": [],
"id": 1
}Event and Log Methods
eth_getLogs
Returns logs matching the filter criteria.
{
"jsonrpc": "2.0",
"method": "eth_getLogs",
"params": [
{
"fromBlock": "0x1",
"toBlock": "latest",
"address": "0x...",
"topics": ["0x..."]
}
],
"id": 1
}eth_newFilter
Creates a filter for logs.
{
"jsonrpc": "2.0",
"method": "eth_newFilter",
"params": [
{
"fromBlock": "latest",
"address": "0x...",
"topics": ["0x..."]
}
],
"id": 1
}π WebSocket Subscriptions
Subscribing to Events
const WebSocket = require('ws');
const ws = new WebSocket('wss://rpc.testnet.goliath.net/ws');
ws.on('open', () => {
// Subscribe to new blocks
ws.send(JSON.stringify({
jsonrpc: '2.0',
method: 'eth_subscribe',
params: ['newHeads'],
id: 1
}));
});
ws.on('message', (data) => {
const response = JSON.parse(data);
console.log('New block:', response.params.result);
});Subscription Types
newHeads
New block headers
logs
Smart contract events
pendingTransactions
Pending transaction hashes
syncing
Sync status updates
β½ Gas Optimization
Gas Price Recommendations
Low
0.5 Gwei
10-30 seconds
Standard
1 Gwei
3-10 seconds
Fast
2 Gwei
< 3 seconds
Instant
5 Gwei
Next block
Gas Limits
Simple Transfer
21,000
~0.000021
ERC-20 Transfer
65,000
~0.000065
Smart Contract Deploy
500,000+
~0.0005+
Complex DeFi Interaction
300,000+
~0.0003+
π Rate Limits
Public Endpoints
Requests per second
100
Requests per minute
3,000
WebSocket connections
10 per IP
Batch request size
100 calls
Enterprise Limits
Contact us for enterprise-grade limits with:
Unlimited requests
Dedicated infrastructure
Custom SLAs
Priority support
π Error Codes
-32700
Parse error
Invalid JSON
-32600
Invalid request
Invalid method
-32601
Method not found
Method doesn't exist
-32602
Invalid params
Invalid parameters
-32603
Internal error
Server error
-32000
Execution reverted
Smart contract error
-32001
Resource not found
Block/tx not found
-32002
Resource unavailable
Node syncing
-32003
Transaction rejected
Invalid transaction
-32004
Method not supported
Unsupported method
-32005
Rate limit exceeded
Too many requests
π Advanced Features
Batch Requests
Send multiple requests in a single call:
[
{
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [],
"id": 1
},
{
"jsonrpc": "2.0",
"method": "eth_gasPrice",
"params": [],
"id": 2
}
]Custom RPC Methods
Goliath extends the standard Ethereum RPC with:
goliath_getNodeInfo
Node information
goliath_getNetworkStats
Network statistics
goliath_getValidators
Active validators
goliath_getFeeSchedule
Current fee structure
π§ Integration Examples
MetaMask Configuration
await window.ethereum.request({
method: 'wallet_addEthereumChain',
params: [{
chainId: '0x127',
chainName: 'Goliath Testnet',
nativeCurrency: {
name: 'XCN',
symbol: 'XCN',
decimals: 18
},
rpcUrls: ['https://rpc.testnet.goliath.net'],
blockExplorerUrls: ['https://testnet.explorer.goliath.net']
}]
});Hardhat Configuration
module.exports = {
networks: {
goliath: {
url: "https://rpc.testnet.goliath.net",
chainId: 8901,
accounts: [process.env.PRIVATE_KEY]
}
}
};π― Best Practices
Connection Management
Use connection pooling for high-volume applications
Implement retry logic with exponential backoff
Cache responses when appropriate
Monitor rate limits to avoid throttling
Error Handling
try {
const result = await web3.eth.call(transaction);
} catch (error) {
if (error.code === -32000) {
console.error('Transaction reverted:', error.message);
} else if (error.code === -32005) {
console.error('Rate limit exceeded, retry later');
} else {
console.error('Unexpected error:', error);
}
}π Additional Resources
π€ Support
Telegram: Developer support channel
GitHub: Report issues and bugs
Enterprise: Contact for dedicated support
The Goliath EVM Gateway provides seamless Ethereum compatibility with enterprise-grade performance and reliability.
Last updated