JSON-RPC API for OKTC: A Comprehensive Guide

ยท

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

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

MethodNamespaceSupportedNotes
web3_clientVersionWeb3YesRetrieves the client version.
web3_sha3Web3YesComputes Keccak-256 hash.
net_versionNetYesReturns current network ID.
eth_protocolVersionEthYesProvides Ethereum protocol version.
eth_syncingEthYesChecks sync status.
eth_gasPriceEthYesFetches 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:

Example Request:

{"jsonrpc":"2.0","method":"web3_sha3","params":["0x68656c6c6f20776f726c64"],"id":1}

Eth Methods

eth_getBalance

Returns the balance of a specified account.

Parameters:

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.