JSON-RPC
JSON-RPC is a remote procedure call (RPC) protocol encoded in JSON (JavaScript Object Notation).
It allows developers to interact with the blockchain by sending HTTP requests to a W Chain node. JSON-RPC provides a simple and lightweight way to execute methods on a remote server (in this case, a W Chain node) and retrieve data such as account balances, transaction details, and smart contract states.
Purpose in W Chain: In W Chain, JSON-RPC is used to facilitate communication between decentralized applications (dApps) and the blockchain. Developers can use JSON-RPC to:
Query blockchain data (e.g., account balances, block details).
Submit transactions to the network.
Interact with deployed smart contracts.
Monitor blockchain events in real-time.
JSON-RPC is essential for integrating W Chain with external applications, enabling seamless blockchain interaction over HTTP or WebSockets.
Transaction, State, History
The core JSON-RPC methods for W Chain can be categorized into three main areas: Transaction, State, and History. These methods allow developers to interact with W Chain's data, whether they need to send transactions, query the current state of accounts, or access historical blockchain data. Use the links to explore each method.
Methods
eth_blockNumber
eth_chainId
eth_gasPrice
eth_getLogs
eth_getBalance
eth_getTransactionByHash
eth_getTransactionReceipt
eth_maxPriorityFeePerGas
Example Usage of JSON-RPC in W Chain
Querying Account Balance
One common use case for JSON-RPC is querying an account's balance. This is important for developers to determine whether an account has sufficient funds for transactions.
Command:
Explanation: This JSON-RPC request retrieves the current balance of the specified account (0x0000000000000000000000000000000000001001). The balance is returned as hexadecimals number in Wei, the smallest unit of EVM native currency, you need to factor the 18 decimals to get the human readable format.
Returned Value:
Submit a Transaction
Developers can also use JSON-RPC to send transactions to the W Chain network, allowing them to move tokens or interact with smart contracts.
Last updated