JSON-RPC Methods
Complete reference for all JSON-RPC methods supported by VIDDHANA.
Chain Methods
eth_chainId
Returns the current chain ID.
Parameters: None
Returns: string - Hex-encoded chain ID
# Request
curl -X POST https://rpc.viddhana.com \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}'
# Response
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x1e61" // 7777 in decimal (mainnet)
}
eth_blockNumber
Returns the current block number.
Parameters: None
Returns: string - Hex-encoded block number
# Request
{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}
# Response
{"jsonrpc":"2.0","id":1,"result":"0x1a2b3c"}
Account Methods
eth_getBalance
Returns the balance of an account.
Parameters:
address- Account addressblock- Block number or tag (latest,pending,earliest)
Returns: string - Balance in wei (hex)
# Request
{
"jsonrpc": "2.0",
"method": "eth_getBalance",
"params": ["0x742d35Cc6634C0532925a3b844Bc9e7595f0Ab1F", "latest"],
"id": 1
}
# Response
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x56bc75e2d63100000" // 100 VDH in wei
}
eth_getTransactionCount
Returns the number of transactions sent from an address (nonce).
Parameters:
address- Account addressblock- Block number or tag
Returns: string - Nonce (hex)
# Request
{
"jsonrpc": "2.0",
"method": "eth_getTransactionCount",
"params": ["0x742d35Cc6634C0532925a3b844Bc9e7595f0Ab1F", "latest"],
"id": 1
}
# Response
{"jsonrpc":"2.0","id":1,"result":"0x5"}
Block Methods
eth_getBlockByNumber
Returns block information by block number.
Parameters:
blockNumber- Block number (hex) or tagfullTransactions- Iftrue, returns full transaction objects
Returns: Block object or null
# Request
{
"jsonrpc": "2.0",
"method": "eth_getBlockByNumber",
"params": ["latest", false],
"id": 1
}
# Response
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"number": "0x1a2b3c",
"hash": "0x...",
"parentHash": "0x...",
"timestamp": "0x...",
"transactions": ["0x...", "0x..."],
"gasUsed": "0x...",
"gasLimit": "0x..."
}
}
eth_getBlockByHash
Returns block information by block hash.
Parameters:
blockHash- 32-byte block hashfullTransactions- Iftrue, returns full transaction objects
Returns: Block object or null
Transaction Methods
eth_sendRawTransaction
Submits a signed transaction to the network.
Parameters:
signedTxData- Signed transaction data (hex)
Returns: string - Transaction hash
# Request
{
"jsonrpc": "2.0",
"method": "eth_sendRawTransaction",
"params": ["0xf86c..."],
"id": 1
}
# Response
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"
}
eth_getTransactionByHash
Returns transaction information by hash.
Parameters:
txHash- Transaction hash
Returns: Transaction object or null
# Request
{
"jsonrpc": "2.0",
"method": "eth_getTransactionByHash",
"params": ["0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"],
"id": 1
}
# Response
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"hash": "0x88df...",
"from": "0x...",
"to": "0x...",
"value": "0x...",
"gas": "0x...",
"gasPrice": "0x...",
"input": "0x...",
"nonce": "0x...",
"blockHash": "0x...",
"blockNumber": "0x...",
"transactionIndex": "0x0"
}
}
eth_getTransactionReceipt
Returns the receipt of a transaction.
Parameters:
txHash- Transaction hash
Returns: Receipt object or null
Contract Methods
eth_call
Executes a read-only contract call.
Parameters:
callObject- Transaction call objectblock- Block number or tag
Returns: string - Return data (hex)
# Request
{
"jsonrpc": "2.0",
"method": "eth_call",
"params": [
{
"to": "0xContractAddress",
"data": "0x70a08231000000000000000000000000YourAddress"
},
"latest"
],
"id": 1
}
# Response
{"jsonrpc":"2.0","id":1,"result":"0x0000000000000000000000000000000000000000000000056bc75e2d63100000"}
eth_estimateGas
Estimates gas required for a transaction.
Parameters:
callObject- Transaction call object
Returns: string - Estimated gas (hex)
eth_getLogs
Returns logs matching filter criteria.
Parameters:
filterObject- Filter parameters
Returns: Array of log objects
# Request
{
"jsonrpc": "2.0",
"method": "eth_getLogs",
"params": [{
"fromBlock": "0x1",
"toBlock": "latest",
"address": "0xContractAddress",
"topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]
}],
"id": 1
}
VIDDHANA-Specific Methods
vdh_getValidators
Returns the current validator set.
Parameters: None
Returns: Array of validator objects
# Request
{"jsonrpc":"2.0","method":"vdh_getValidators","params":[],"id":1}
# Response
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"address": "0x...",
"stake": "1000000000000000000000",
"commission": "0.05",
"uptime": "99.9"
}
]
}
vdh_getStakingInfo
Returns staking statistics.
Parameters:
address(optional) - Staker address
Returns: Staking info object
vdh_getAIPrediction
Query Prometheus AI for predictions.
Parameters:
asset- Asset symbol (e.g., "BTC", "ETH")horizon- Prediction horizon in days
Returns: Prediction object
# Request
{
"jsonrpc": "2.0",
"method": "vdh_getAIPrediction",
"params": ["BTC", 7],
"id": 1
}
# Response
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"asset": "BTC",
"currentPrice": "67500.00",
"predictedPrice": "69200.00",
"confidence": "0.78",
"horizon": 7,
"timestamp": "2024-01-15T12:00:00Z"
}
}
See also: API Overview | JavaScript SDK