This documentation outlines the JSON-RPC methods and namespaces supported by OKTC, providing developers with the tools needed to interact with the blockchain efficiently.
Supported Networks
Mainnet
- Chain ID:
0x42(66 in decimal) - RPC Endpoint:
https://exchainrpc.okex.org/
Third-Party Providers
Details on integrating with third-party RPC providers are available upon request.
Prerequisites
Before diving into the JSON-RPC methods, familiarize yourself with the Ethereum JSON-RPC specifications to understand the foundational protocols.
Getting Started with HTTP JSON-RPC
Initiate HTTP JSON-RPC interactions using curl for simplicity. Alternatively, use geth by downloading it from the official site or building from source.
JSON-RPC Methods Overview
| Method | Namespace | Supported | Notes |
|---|---|---|---|
web3_clientVersion | Web3 | Yes | Retrieves the client version. |
web3_sha3 | Web3 | Yes | Computes Keccak-256 hash. |
net_version | Net | Yes | Returns current network ID. |
eth_protocolVersion | Eth | Yes | Provides Ethereum protocol version. |
eth_syncing | Eth | Yes | Checks sync status. |
eth_gasPrice | Eth | Yes | Fetches current gas price in OKT. |
๐ Explore all supported methods
Detailed Method Explanations
Web3 Methods
web3_clientVersion
Retrieves the version of the Web3 client.
Example Request:
{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}web3_sha3
Returns the Keccak-256 hash of the provided data.
Parameters:
data: String to hash.
Example Request:
{"jsonrpc":"2.0","method":"web3_sha3","params":["0x68656c6c6f20776f726c64"],"id":1}Eth Methods
eth_getBalance
Returns the balance of a specified account.
Parameters:
address: 20-byte account address.block: Block number or tag ("latest","earliest","pending").
Example Request:
{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x407d73d8a49eeb85d32cf465507dd71d507100c1", "latest"],"id":1}๐ Learn more about Eth methods
FAQs
What is JSON-RPC?
JSON-RPC is a lightweight remote procedure call protocol that uses JSON to encode messages. It's widely used in blockchain interactions for its simplicity and efficiency.
How do I subscribe to block updates?
Use eth_subscribe with "newHeads" as the subscription type to receive notifications about new blocks.
Can I send transactions without unlocking my account?
Yes, using eth_sendRawTransaction with a pre-signed transaction allows you to send transactions without account unlocking.
Conclusion
This guide provides a thorough overview of the JSON-RPC API available on OKTC. For further details, refer to the official documentation or explore advanced use cases with the provided examples.