Skip to content
/ tjrp Public

JSON-RPC proxy for TRON blockchain. It makes TRON more compatible with Ethereum tools, such as alloy and foundry

Notifications You must be signed in to change notification settings

u59149403/tjrp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TJRP - TRON JSON-RPC proxy

This is JSON-RPC proxy for TRON blockchain. It makes TRON more compatible with Ethereum tools, such as alloy and foundry.

Usage

Install Rust. Clone this repo. In this directory run:

# For Nile testnet
cargo run -- proxy https://nile.trongrid.io/jsonrpc false 127.0.0.1:4639

Usage: <program> proxy PARENT-JSON-RPC FAKE-SOME-APIS LISTEN-AT

Options:

  • PARENT-JSON-RPC - parent JSON-RPC. This is JSON-RPC our proxy connects too. See TRON JSON-RPCs here: https://developers.tron.network/docs/networks
  • FAKE-SOME-APIS - whether to fake some APIs (see below). true or false
  • LISTEN-AT - IP address and port for listening. For example, 127.0.0.1:4639 (listen locally) or 0.0.0.0:4639 (allow whole world to connect)

Also, as a convenience feature, there are subcommands from-tron and to-tron for address converting:

$ cargo run -- to-tron 0xD91E708140DdAebA75af09da9A172333c71eD56B
TVmE6f78MLxmvFwd53pq1R4i7KqgJwxSDQ
$ cargo run -- from-tron TVmE6f78MLxmvFwd53pq1R4i7KqgJwxSDQ
0xD91E708140DdAebA75af09da9A172333c71eD56B

Status

Currently very few things are implemented. But notably this proxy allows you to call view methods of contracts. I. e. now you can call alloy's CallBuilder::call (you cannot do this with standard TRON JSON-RPCs directly).

Many other things are not supported. Sending transactions doesn't work. anvil seems not to work, too.

If you specify FAKE-SOME-APIS as true, then TJRP will provide some fake data to enhance compatibility:

  • eth_getTransactionCount will always return 0
  • eth_getCode and eth_getBalance will return current data for non-latest blocks

If you specify it as false, then TJRP will return error instead in these cases.

Currently TJRP provides very little utility. But still it is useful as a starting point.

Currently I don't see much interest in continuing to develop TJRP. But you may contact me and offer some money for this. I totally understand how to implement all missing functionality. Well, it is not possible to implement eth_call (and some other calls) for historic calls at TJRP level, you can only fake it. But it is possible to implement nearly everything else. In the end nearly all calls will be implemented. Some of them for real, others - by returning current data instead of historic. And yes, anvil will work. So, if you want me to continue developing, contact me and offer some money.

If you have anything to say, open an issue.

If you like this project, give it a Github star.

Donations are welcome, they will definitely increase my motivation to work on the project. Ethereum mainnet: 0xD91E708140DdAebA75af09da9A172333c71eD56B, send ether or any stablecoins. TRON: TVmE6f78MLxmvFwd53pq1R4i7KqgJwxSDQ, send TRX or any stablecoins.

Author: https://github.com/u59149403, [email protected]

License: MIT OR Apache-2.0

About

JSON-RPC proxy for TRON blockchain. It makes TRON more compatible with Ethereum tools, such as alloy and foundry

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages