Documentation
Learn everything about the Theta Network.

Ethereum RPC API support

Since version v3.1.0 (released on July 30, 2021), the Theta blockchain supports the Ethereum RPC APIs through the Theta ETH RPC Adpator, which translates the Theta RPC interface into the Ethereum RPC interface.

Setup Theta Local Privatenet with Ethereum RPC Adaptor

If you want to setup a local privatenet for testing purpose, this guide would walk you through the steps to launch a local Theta privatenet, and the accompanying Ethereum RPC adaptor. This setup can be used as a tool to run local tests, similar to ganache in the Truffle suite. The Chain ID for the Theta Privatenet is 366.

Ethereum RPC APIs for the Theta Mainnet

We are hosting the Ethereum RPC adaptor for the Theta Mainnet at the URL below. The Chain ID for the Theta Mainnet is 361.

https://eth-rpc-api.thetatoken.org/rpc

The following examples demonstrate how to interact with the Theta Mainnet through the above RPC endpoint with the curl command:

# Query Chain ID
curl -X POST -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":67}' https://eth-rpc-api.thetatoken.org/rpc

# Query synchronization status
curl -X POST -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' https://eth-rpc-api.thetatoken.org/rpc

# Query block number
curl -X POST -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}' https://eth-rpc-api.thetatoken.org/rpc

# Query account TFuel balance (should return an integer which represents the current TFuel balance in wei)
curl -X POST -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xc15149236229bd13f0aec783a9cc8e8059fb28da", "latest"],"id":1}' https://eth-rpc-api.thetatoken.org/rpc

We currently support the following Ethereum RPC methods:

eth_chainId
eth_syncing
eth_accounts
eth_protocolVersion
eth_getBlockByHash
eth_getBlockByNumber
eth_blockNumber
eth_getUncleByBlockHashAndIndex
eth_getTransactionByHash
eth_getTransactionByBlockNumberAndIndex
eth_getTransactionByBlockHashAndIndex
eth_getBlockTransactionCountByHash
eth_getTransactionReceipt
eth_getBalance
eth_getStorageAt
eth_getCode
eth_getTransactionCount
eth_getLogs
eth_getBlockTransactionCountByNumber
eth_call
eth_gasPrice
eth_estimateGas
eth_sendRawTransaction
eth_sendTransaction
eth_sign
eth_signTypedData
net_version
web3_clientVersion

Note 1: Currently the RPC Adaptor does NOT support non-standard methods like evm_snapshot, evm_revert, and evm_mine. Thus, test cases using Fixtures (e.g. waffle.loadFixture()) are expected to fail when running against the Theta blockchain.

Note 2: Currently the RPC Adaptor returns a generic "evm: execution reverted" messages in most case when the Theta EVM execution fails. Some test cases may check the EVM errors with code like this:

await expect(this.bar.leave("200")).to.be.revertedWith("ERC20: burn amount exceeds balance")

To make these test pass, for now we need to replace the expected error message with "evm: execution reverted" as shown below:

await expect(this.bar.leave("200")).to.be.revertedWith("evm: execution reverted")

Ethereum RPC APIs for the Theta Testnet

The Ethereum RPC adaptor for the Theta Testnet is hosted at the following URL. The Chain ID for the Theta Testnet is 365.

https://eth-rpc-api-testnet.thetatoken.org/rpc

If you need testnet Theta/TFuel for DApp development purpose, please contact us at [email protected]

Updated about a month ago



Ethereum RPC API support


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.