Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for eth_simulateV1 Method in Tron JSON-RPC #6199

Open
VladLypovyi opened this issue Feb 18, 2025 · 6 comments
Open

Add Support for eth_simulateV1 Method in Tron JSON-RPC #6199

VladLypovyi opened this issue Feb 18, 2025 · 6 comments

Comments

@VladLypovyi
Copy link

Background

Currently, Ethereum provides the eth_simulateV1 method, which allows developers to simulate transactions before broadcasting them. This is useful for estimating gas usage, detecting potential reverts, and debugging smart contract interactions. However, Tron Protocol does not currently support this method, which limits the ability of developers to perform pre-execution checks efficiently.

Rationale

Why should this feature exist?

  • Enhances developer experience by allowing transaction simulation before execution.
  • Reduces the risk of failed transactions due to insufficient resources or contract failures.
  • Aligns Tron’s JSON-RPC API with Ethereum’s, improving compatibility for developers building cross-chain applications.

What are the use-cases?

  • Gas and Energy Estimation: Developers can estimate energy consumption and fees before executing a transaction.
  • Smart Contract Debugging: Allows developers to test interactions with contracts without submitting real transactions.
  • Transaction Outcome Prediction: Helps applications check whether a transaction will succeed before submitting it to the network.

Specification

The eth_simulateV1 method should be implemented in the Tron JSON-RPC API, following Ethereum’s standard behavior. The method should:

  • Accept transaction input parameters similar to eth_call.
  • Return execution results, including status, logs, and estimated energy used.
  • Handle different contract call scenarios, including internal calls and delegate calls.
  • Provide error messages if the transaction would fail.

Scope Of Impact

  • Requires changes to the Tron JSON-RPC API.
  • May require modifications to the execution engine to provide accurate simulation results.
  • No backward compatibility issues, as this is a new method.
@DmytroShalaiev
Copy link

+1, I am also interested in this feature

@DmytroShalaiev
Copy link

@abn2357
Copy link

abn2357 commented Feb 19, 2025

Two questions about this proposal:

  1. What is the approximate error between simulated transaction and real transaction. Is there any statistical data on ethereum?
  2. After what interval, it is necessary to re simulate. Is there a recommended time for this interval?

@yanghang8612
Copy link
Contributor

yanghang8612 commented Feb 19, 2025

As you say, eth_simulateV1 is a very versatile new interface.

Of course on TRON you can implement a similar simulation via /wallet/triggerconstantcontract, but the implementation details and return values are not the same as eth_simulateV1.

We will look into eth_simulateV1 as soon as possible and will continue to report back here as we make any progress.

Thank you for your suggestion.

@DmytroShalaiev
Copy link

We will look into eth_simulateV1 as soon as possible

Thanks so much

@Sunny6889
Copy link

How can we prevent users from abusing this feature? I assume there should be a fee associated with calling this API. If so, how is the fee calculated?

@halibobo1205 halibobo1205 moved this to Backlog in java-tron Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

5 participants