Skip to content

feat(jsonrpc): implement base eth_simulateV1 JSON-RPC method#6785

Open
APshenkin wants to merge 4 commits into
tronprotocol:developfrom
APshenkin:feature/simulate-mvp
Open

feat(jsonrpc): implement base eth_simulateV1 JSON-RPC method#6785
APshenkin wants to merge 4 commits into
tronprotocol:developfrom
APshenkin:feature/simulate-mvp

Conversation

@APshenkin
Copy link
Copy Markdown

@APshenkin APshenkin commented May 19, 2026

What does this PR do?

Implements geth's eth_simulateV1 on java-tron's JSON-RPC surface for the MVP trading-flow use case: a single round-trip that runs N dependent calls against current head state and returns each call's effect plus synthetic transfer logs.

The endpoint is opt-in via existing eth_call-style flags; no existing behaviour changes.

Why are these changes required?

This is first step to resolve #6199

Tron's JSON-RPC exposes eth_call but not eth_simulateV1. Two concrete consumers benefit:

  1. Trading flows that build raw EVM transactions that depend on each other (approval → swap → settle) and need to verify the actual output of the chain — what each step returns, which logs it emits, how balances move — before broadcasting.
  2. Wallets integrating with dapp-connect protocols (WalletConnect-style sign requests). Before the user signs, the wallet UI wants to show what the transaction will actually do: token transfers in/out, TRC20/TRX value movement, contract state changes. eth_simulateV1 lets the wallet run the unsigned transaction against current head state and decode the resulting transfer logs directly into a human-readable diff.

Both consumers simulate against current head state only — they don't need historical-block context or state overrides. The current implementation covers those cases end-to-end and is sufficient for what we expect to be the majority of eth_simulateV1 usage on Tron.

Future work needed for the remaining use cases (debugging historical txs, what-if analysis with state overrides) requires changes in the archive node to support simulation on a specific block + stateOverrides / blockOverrides. That's intentionally out of scope here.

JSON-RPC surface

  • One simulation block per request: blockStateCalls: [{ calls: [...] }]. Multi-block / blockOverrides / stateOverrides-32602. blockOverrides and stateOverrides are excluded by design — both consumers in the Motivation section simulate against current head state only, and supporting overrides would require the same archive-node plumbing called out as future work (rewinding to a specific block, applying account/storage patches before VM execution). Rejecting them with a clear error is better than silently ignoring them. Hard cap of 32 calls per block — geth's defaults (5000/block, 10000 total) are tuned for general-purpose use; our concrete cases (trading-flow approval+swap+settle, wallet preview of a single user-signed tx that fans out a few internal calls) realistically stay under ~10. Capping at 32 leaves comfortable headroom while bounding per-request memory: at ~10KB of accumulated state per call, the shared root's in-memory cache stays well under ~1MB worst-case (vs ~50MB at 5000). Anything beyond that should either be a separate request or signal misuse.
  • blockNumOrTag: only "latest" and "pending" accepted; both resolve to the head block (Tron has instant finality — no mempool state distinct from latest).
  • traceTransfers: true synthesizes logs at the ERC-7528 native pseudo-address (0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE), distinguished by topic[0]:
    • Transfer(address,address,uint256) for native TRX moves.
    • TRC10Transfer(address,address,uint256,uint256) for TRC-10 moves — topic[3] carries tokenId so consumers can filter logs by asset via topics; data carries amount.
  • returnFullTransactions: true returns block.transactions as TransactionResult objects (synthetic deterministic hash, gasPrice = "0x0", nonce = "0x0", v/r/s zero, blockHash = keccak256("sim:" + headHash + ":1")). Default false returns hash strings.
  • validation: true — Tron-flavored. Geth's checks (baseFee / gasPrice / nonce) don't apply to Tron, so we pre-check per call: sender account exists and sender balance ≥ callValue. Failed pre-check → status: "0x0" with errorMessage, VM not invoked. Default false preserves the existing constant-call permissive behaviour.

Tracing

Five hook sites per transfer kind, each firing after the real balance change succeeds:

Site TRX TRC-10
VMActuator.call() (depth 0) after MUtil.transfer after MUtil.transferToken
VMActuator.create() (depth 0) after MUtil.transfer after MUtil.transferToken
Program.callToAddress (depth ≥1) after addBalance pair after addTokenBalance pair
Program.callToPrecompiledAddress (depth ≥1) after precompile transfer after addTokenBalance pair
Program.suicide / suicide2 after MUtil.transfer new transferAllTokenWithTrace helper — snapshot assetMapV2 before MUtil.transferAllToken, emit one entry per non-zero asset

DELEGATECALL / CALLCODE are explicitly skipped (no real value transfer even when senderAddress != contextAddress).

A per-frame buffer (BufferingSimulationTracer) with a unified seq counter interleaves explicit LOG opcodes with both synthetic kinds in emission order. Reverted frames drop their entries; logIndex still increments through gaps (matches geth's logtracer.go:128).

Implementation

  • New listener SPI: SimulationTracer (enterFrame / exitFrame / revertFrame / onTransfer / onTokenTransfer / onLog). Default impl BufferingSimulationTracer owns the frame stack and seq counter.
  • VMActuator gets opt-in setters (setInjectedRootRepository, setSimulationTracer). When the injected root is null, the existing fresh-root code path runs unchanged.
  • Program propagates the tracer into child Program instances at every sub-call origination site so nested CALL/CREATE moves are captured.
  • Wallet.simulateConstantContracts is the new entry point. It builds the shared root + per-call child Repositories and shares the per-call execute body with the existing callConstantContract via a new private executeOneConstantInternal helper.
  • DTOs: SimulateV1Args, SimulateBlock (uses @JsonAnySetter to detect forward-incompatible field names), SimulateCallResult, SimulateBlockResult extends BlockResult. Reuses LogFilterElement, CallArguments, TransactionResult (additive raw-fields constructor for synthetic full-tx output).

This PR has been tested by:

Unit

20 tests total:

gradle :framework:test --tests "org.tron.core.jsonrpc.EthSimulateV1*"

Unit (EthSimulateV1ArgsTest, 11 tests)

-32602 input-validation surface, JSON round-trip of SimulateBlockResult, non-numeric tokenId rejection. Mocked Wallet, no chain context.

Integration (EthSimulateV1IntegrationTest, 9 tests, BaseTest + LevelDB)

  • stateSharingAcrossCallsset(42)get() returns 42 in one simulate; on-chain slot unchanged.
  • revertIsolatesPerCallset(99)setRevert(123)get() returns 99.
  • validationRejectsUnactivatedSendervalidation: true with a never-seen from"sender account does not exist".
  • validationRejectsInsufficientBalancevalidation: true with value > balance"insufficient balance for value".
  • createPopulatesContractAddress — CREATE call sets contractAddress to the actual deployed address (read from the VM, not re-synthesized).
  • returnFullTransactionsShape — verifies both response shapes, deterministic hash equality across runs.
  • traceTrc10TopLevelCall — owner sends 50 units of token 1000001 to the pre-deployed contract; verifies all four topics + data; owner on-chain TRC-10 balance unchanged.
  • traceTrc10MixedWithTrx — single call with both value: "0x64" and tokenValue: "0x32" to an "accept-anything" sink contract; both synthetic logs emitted in TRX-first order.
  • buffering_dropsTokenTransferOnRevertFrame — direct buffer exercise: revertFrame drops a buffered onTokenTransfer.

Manual Testing

Launched Nile testnet node with changes and run multiple commands with different setups:

Requests and Responses are long, so hide under spoiler
// simulate TRC10 internal transactions
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_simulateV1",
  "params": [
    {
      "blockStateCalls": [
        {
          "calls": [
            {
              "from": "0x93a8ec1D0698a3873E942A4e3b65A6c20F7310d3",
              "to": "0xCa77E26553571DCD4e5e5377F39D49a17da4c1d2",
              "data": "0x1dc9139d00000000000000000000000093a8ec1d0698a3873e942a4e3b65a6c20f7310d300000000000000000000000000000000000000000000000000000000000f5e880000000000000000000000000000000000000000000000000000000000000007",
              "value": "0x0"
            }
          ]
        }
      ],
      "traceTransfers": true,
      "returnFullTransactions": false,
      "validation": true
    },
    "latest"
  ]
}

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    {
      "baseFeePerGas": "0x0",
      "calls": [
        {
          "contractAddress": "0xca77e26553571dcd4e5e5377f39d49a17da4c1d2",
          "gasUsed": "0x1c09",
          "logs": [
            {
              "address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
              "blockHash": "0x74658adc76f7767802356a499daff01c2ceb508c8b6001f72630f228be52b606",
              "blockNumber": "0x4070777",
              "blockTimestamp": "0x6a0c63ab",
              "data": "0x0000000000000000000000000000000000000000000000000000000000000007",
              "logIndex": "0x0",
              "removed": false,
              "topics": [
                "0xe917b6ed800090e45df2bef0c9b375f409f3565e1ecada6f3e04aca5bb191ea0",
                "0x000000000000000000000000ca77e26553571dcd4e5e5377f39d49a17da4c1d2",
                "0x00000000000000000000000093a8ec1d0698a3873e942a4e3b65a6c20f7310d3",
                "0x00000000000000000000000000000000000000000000000000000000000f5e88"
              ],
              "transactionHash": "0xfdaac4eb9c153654b21f434574514011d839c8bde04a0ed0122b8850bbda5c65",
              "transactionIndex": "0x0"
            }
          ],
          "returnData": "0x",
          "status": "0x1",
          "transactionHash": "0xfdaac4eb9c153654b21f434574514011d839c8bde04a0ed0122b8850bbda5c65",
          "transactionIndex": "0x0"
        }
      ],
      "difficulty": "0x0",
      "extraData": "0x",
      "gasLimit": "0x5f5e100",
      "gasUsed": "0x1c09",
      "hash": "0x74658adc76f7767802356a499daff01c2ceb508c8b6001f72630f228be52b606",
      "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "miner": "0x0000000000000000000000000000000000000000",
      "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "nonce": "0x0000000000000000",
      "number": "0x4070777",
      "parentHash": "0x0000000004070776f962952b0d110f2f4955edc721b308c0642dc1f890d1d812",
      "receiptsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "sha3Uncles": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "size": "0x0",
      "stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "timestamp": "0x6a0c63ad",
      "totalDifficulty": "0x0",
      "transactions": [
        "0xfdaac4eb9c153654b21f434574514011d839c8bde04a0ed0122b8850bbda5c65"
      ],
      "transactionsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "uncles": []
    }
  ]
}

// simulate TRX internal transactions (WTRX withdraw method)
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_simulateV1",
  "params": [
    {
      "blockStateCalls": [
        {
          "calls": [
            {
              "from": "0x72f09FB677a83C9CD56cE1A4179afEbC348Fc6D4",
              "to": "0xfb3b3134F13CcD2C81F4012E53024e8135d58FeE",
              "data": "0x2e1a7d4d000000000000000000000000000000000000000000000000000000000082ad8c",
              "value": "0x0"
            }
          ]
        }
      ],
      "traceTransfers": true,
      "returnFullTransactions": true,
      "validation": false
    },
    "latest"
  ]
}

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    {
      "baseFeePerGas": "0x0",
      "calls": [
        {
          "contractAddress": "0xfb3b3134f13ccd2c81f4012e53024e8135d58fee",
          "gasUsed": "0x3697",
          "logs": [
            {
              "address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
              "blockHash": "0x2534e0fd73b47c60f93ca4fb8abf2e8ca09350666a33d4f8d3566f7a3b5dcceb",
              "blockNumber": "0x40707c2",
              "blockTimestamp": "0x6a0c648c",
              "data": "0x000000000000000000000000000000000000000000000000000000000082ad8c",
              "logIndex": "0x0",
              "removed": false,
              "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                "0x000000000000000000000000fb3b3134f13ccd2c81f4012e53024e8135d58fee",
                "0x00000000000000000000000072f09fb677a83c9cd56ce1a4179afebc348fc6d4"
              ],
              "transactionHash": "0x655b5bc23d3cfbbe6f6831921100615af427ed485ef1ad749e69df3911955fa8",
              "transactionIndex": "0x0"
            },
            {
              "address": "0xfb3b3134f13ccd2c81f4012e53024e8135d58fee",
              "blockHash": "0x2534e0fd73b47c60f93ca4fb8abf2e8ca09350666a33d4f8d3566f7a3b5dcceb",
              "blockNumber": "0x40707c2",
              "blockTimestamp": "0x6a0c648c",
              "data": "0x000000000000000000000000000000000000000000000000000000000082ad8c",
              "logIndex": "0x1",
              "removed": false,
              "topics": [
                "0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65",
                "0x00000000000000000000000072f09fb677a83c9cd56ce1a4179afebc348fc6d4"
              ],
              "transactionHash": "0x655b5bc23d3cfbbe6f6831921100615af427ed485ef1ad749e69df3911955fa8",
              "transactionIndex": "0x0"
            }
          ],
          "returnData": "0x",
          "status": "0x1",
          "transactionHash": "0x655b5bc23d3cfbbe6f6831921100615af427ed485ef1ad749e69df3911955fa8",
          "transactionIndex": "0x0"
        }
      ],
      "difficulty": "0x0",
      "extraData": "0x",
      "gasLimit": "0x5f5e100",
      "gasUsed": "0x3697",
      "hash": "0x2534e0fd73b47c60f93ca4fb8abf2e8ca09350666a33d4f8d3566f7a3b5dcceb",
      "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "miner": "0x0000000000000000000000000000000000000000",
      "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "nonce": "0x0000000000000000",
      "number": "0x40707c2",
      "parentHash": "0x00000000040707c1987b1b6a3cfa11bcdd920bf3542d411f86aa9fc35867a32a",
      "receiptsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "sha3Uncles": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "size": "0x0",
      "stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "timestamp": "0x6a0c648e",
      "totalDifficulty": "0x0",
      "transactions": [
        "0x655b5bc23d3cfbbe6f6831921100615af427ed485ef1ad749e69df3911955fa8"
      ],
      "transactionsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "uncles": []
    }
  ]
}

// simulate TRX internal transactions (WTRX deposit method)
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_simulateV1",
  "params": [
    {
      "blockStateCalls": [
        {
          "calls": [
            {
              "from": "0x72f09FB677a83C9CD56cE1A4179afEbC348Fc6D4",
              "to": "0xfb3b3134F13CcD2C81F4012E53024e8135d58FeE",
              "data": "0xd0e30db0",
              "value": "0x4C4B40"
            }
          ]
        }
      ],
      "traceTransfers": true,
      "returnFullTransactions": false
    },
    "latest"
  ]
}

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    {
      "baseFeePerGas": "0x0",
      "calls": [
        {
          "contractAddress": "0xfb3b3134f13ccd2c81f4012e53024e8135d58fee",
          "gasUsed": "0x1aa0",
          "logs": [
            {
              "address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
              "blockHash": "0x0baf7e3a971363b293befab76a47e2e49fcd7edc6ec30b649cc02b5a232302d1",
              "blockNumber": "0x40707c8",
              "blockTimestamp": "0x6a0c649e",
              "data": "0x00000000000000000000000000000000000000000000000000000000004c4b40",
              "logIndex": "0x0",
              "removed": false,
              "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                "0x00000000000000000000000072f09fb677a83c9cd56ce1a4179afebc348fc6d4",
                "0x000000000000000000000000fb3b3134f13ccd2c81f4012e53024e8135d58fee"
              ],
              "transactionHash": "0xfda63659d0ba50fe6f10e51da3f03057a7ed2077dd8ccb9a6867ba68fe32cd2b",
              "transactionIndex": "0x0"
            },
            {
              "address": "0xfb3b3134f13ccd2c81f4012e53024e8135d58fee",
              "blockHash": "0x0baf7e3a971363b293befab76a47e2e49fcd7edc6ec30b649cc02b5a232302d1",
              "blockNumber": "0x40707c8",
              "blockTimestamp": "0x6a0c649e",
              "data": "0x00000000000000000000000000000000000000000000000000000000004c4b40",
              "logIndex": "0x1",
              "removed": false,
              "topics": [
                "0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c",
                "0x00000000000000000000000072f09fb677a83c9cd56ce1a4179afebc348fc6d4"
              ],
              "transactionHash": "0xfda63659d0ba50fe6f10e51da3f03057a7ed2077dd8ccb9a6867ba68fe32cd2b",
              "transactionIndex": "0x0"
            }
          ],
          "returnData": "0x",
          "status": "0x1",
          "transactionHash": "0xfda63659d0ba50fe6f10e51da3f03057a7ed2077dd8ccb9a6867ba68fe32cd2b",
          "transactionIndex": "0x0"
        }
      ],
      "difficulty": "0x0",
      "extraData": "0x",
      "gasLimit": "0x5f5e100",
      "gasUsed": "0x1aa0",
      "hash": "0x0baf7e3a971363b293befab76a47e2e49fcd7edc6ec30b649cc02b5a232302d1",
      "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "miner": "0x0000000000000000000000000000000000000000",
      "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "nonce": "0x0000000000000000",
      "number": "0x40707c8",
      "parentHash": "0x00000000040707c759842988bd1086303dcd1bb8a67a606d7dc6cfb2b8cb183c",
      "receiptsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "sha3Uncles": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "size": "0x0",
      "stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "timestamp": "0x6a0c64a0",
      "totalDifficulty": "0x0",
      "transactions": [
        "0xfda63659d0ba50fe6f10e51da3f03057a7ed2077dd8ccb9a6867ba68fe32cd2b"
      ],
      "transactionsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "uncles": []
    }
  ]
}

// simulate error return
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_simulateV1",
  "params": [
    {
      "blockStateCalls": [
        {
          "calls": [
            {
              "from": "0x41C2BED267CAD1D3FCF2AB8DAF21A30B02E502FAA0",
              "to": "0x4123065A627120849CCCFEA5F8C6436EF4C1B65D66",
              "data": "0xcef952290000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000009896800000000000000000000000000000000000000000000000004563918244f40000000000000000000000000000c2bed267cad1d3fcf2ab8daf21a30b02e502faa0000000000000000000000000000000000000000000000000000000006a0c450e0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000eca9bc828a3005b9a3b909f2cc5c2a54794de05f00000000000000000000000037349aeb75a32f8c4c090daff376cf975f5d2eba000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002763200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
              "value": "0x0"
            }
          ]
        }
      ],
      "traceTransfers": true,
      "returnFullTransactions": false
    },
    "latest"
  ]
}

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    {
      "baseFeePerGas": "0x0",
      "calls": [
        {
          "errorData": "0x08c379a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000018556e69737761705632526f757465723a20455850495245440000000000000000",
          "errorMessage": "REVERT opcode executed: UniswapV2Router: EXPIRED",
          "gasUsed": "0x7af1",
          "logs": [],
          "returnData": "0x08c379a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000018556e69737761705632526f757465723a20455850495245440000000000000000",
          "status": "0x0",
          "transactionHash": "0x4f5ee8f5b740311bbf95301f9857f5ce6b80b5f3e42ce838e1cc7e123c9a448a",
          "transactionIndex": "0x0"
        }
      ],
      "difficulty": "0x0",
      "extraData": "0x",
      "gasLimit": "0x5f5e100",
      "gasUsed": "0x7af1",
      "hash": "0xa90a24b9a9fd0fee8fa7dcf9a3c92ac92038b19f6641af69f4d7cc37a58f85e1",
      "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "miner": "0x0000000000000000000000000000000000000000",
      "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "nonce": "0x0000000000000000",
      "number": "0x40707dc",
      "parentHash": "0x00000000040707dbb227def6922c33285babb9055ebaa2d6fbc5e7b497b636e1",
      "receiptsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "sha3Uncles": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "size": "0x0",
      "stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "timestamp": "0x6a0c64dc",
      "totalDifficulty": "0x0",
      "transactions": [
        "0x4f5ee8f5b740311bbf95301f9857f5ce6b80b5f3e42ce838e1cc7e123c9a448a"
      ],
      "transactionsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "uncles": []
    }
  ]
}

// simulate TRC20 transfer from
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_simulateV1",
  "params": [
    {
      "blockStateCalls": [
        {
          "calls": [
            {
              "from": "0x41D5AEF88AAFE8B851FD107B9866159840C38CCCB2",
              "to": "0x41ECA9BC828A3005B9A3B909F2CC5C2A54794DE05F",
              "data": "0x23b872dd000000000000000000000000b738198811642bba819521332da1e22c3f0ccc18000000000000000000000000d5aef88aafe8b851fd107b9866159840c38cccb200000000000000000000000000000000000000000000000000000000000f4240",
              "value": "0x0"
            }
          ]
        }
      ],
      "traceTransfers": true,
      "returnFullTransactions": false
    },
    "latest"
  ]
}

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    {
      "baseFeePerGas": "0x0",
      "calls": [
        {
          "contractAddress": "0xeca9bc828a3005b9a3b909f2cc5c2a54794de05f",
          "gasUsed": "0x4f7d",
          "logs": [
            {
              "address": "0xeca9bc828a3005b9a3b909f2cc5c2a54794de05f",
              "blockHash": "0xa7b4bd465b6f582d106970a39637c7cb505adbccb2bf9ac2870505ec5bf1760b",
              "blockNumber": "0x40707eb",
              "blockTimestamp": "0x6a0c6508",
              "data": "0x00000000000000000000000000000000000000000000000000000000000f4240",
              "logIndex": "0x0",
              "removed": false,
              "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                "0x000000000000000000000000b738198811642bba819521332da1e22c3f0ccc18",
                "0x000000000000000000000000d5aef88aafe8b851fd107b9866159840c38cccb2"
              ],
              "transactionHash": "0x6138abb8f25e21bf10ddca7b5e37367b65b5851cd19e0d305f7e90499ca671a9",
              "transactionIndex": "0x0"
            }
          ],
          "returnData": "0x0000000000000000000000000000000000000000000000000000000000000001",
          "status": "0x1",
          "transactionHash": "0x6138abb8f25e21bf10ddca7b5e37367b65b5851cd19e0d305f7e90499ca671a9",
          "transactionIndex": "0x0"
        }
      ],
      "difficulty": "0x0",
      "extraData": "0x",
      "gasLimit": "0x5f5e100",
      "gasUsed": "0x4f7d",
      "hash": "0xa7b4bd465b6f582d106970a39637c7cb505adbccb2bf9ac2870505ec5bf1760b",
      "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "miner": "0x0000000000000000000000000000000000000000",
      "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "nonce": "0x0000000000000000",
      "number": "0x40707eb",
      "parentHash": "0x00000000040707eafe60e2747598fed79ffb15f4d67938ba648c381307c28ee1",
      "receiptsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "sha3Uncles": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "size": "0x0",
      "stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "timestamp": "0x6a0c6509",
      "totalDifficulty": "0x0",
      "transactions": [
        "0x6138abb8f25e21bf10ddca7b5e37367b65b5851cd19e0d305f7e90499ca671a9"
      ],
      "transactionsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "uncles": []
    }
  ]
}

// Multiple Ops transfers using Swap Contract (TRX -> WTRX -> USDT)
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_simulateV1",
  "params": [
    {
      "blockStateCalls": [
        {
          "calls": [
            {
              "from": "0x93a8ec1D0698a3873E942A4e3b65A6c20F7310d3",
              "to": "0x81839E7bCcDc7D5f50419bC34209d8ae5969Ef66",
              "data": "0x7ff36ab50000000000000000000000000000000000000000000000000000000006d4ee0f000000000000000000000000000000000000000000000000000000000000008000000000000000000000000093a8ec1d0698a3873e942a4e3b65a6c20f7310d3000000000000000000000000000000000000000000000000000000006a0c79dd0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000fb3b3134f13ccd2c81f4012e53024e8135d58fee000000000000000000000000eca9bc828a3005b9a3b909f2cc5c2a54794de05f",
              "value": "0x5F5E100"
            }
          ]
        }
      ],
      "traceTransfers": true,
      "returnFullTransactions": false
    },
    "latest"
  ]
}

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    {
      "baseFeePerGas": "0x0",
      "calls": [
        {
          "contractAddress": "0x81839e7bccdc7d5f50419bc34209d8ae5969ef66",
          "gasUsed": "0x1848c",
          "logs": [
            {
              "address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
              "blockHash": "0x718c2a920c27f6716f04d73677eeaf31a7faec1cd585b86aa7de8678e8559172",
              "blockNumber": "0x4070e93",
              "blockTimestamp": "0x6a0c7912",
              "data": "0x0000000000000000000000000000000000000000000000000000000005f5e100",
              "logIndex": "0x0",
              "removed": false,
              "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                "0x00000000000000000000000093a8ec1d0698a3873e942a4e3b65a6c20f7310d3",
                "0x00000000000000000000000081839e7bccdc7d5f50419bc34209d8ae5969ef66"
              ],
              "transactionHash": "0x344797609db13153fd3c1c23529d7e7b794ddd586d3b6c53dc20fb2343ae3ee4",
              "transactionIndex": "0x0"
            },
            {
              "address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
              "blockHash": "0x718c2a920c27f6716f04d73677eeaf31a7faec1cd585b86aa7de8678e8559172",
              "blockNumber": "0x4070e93",
              "blockTimestamp": "0x6a0c7912",
              "data": "0x0000000000000000000000000000000000000000000000000000000005f5e100",
              "logIndex": "0x1",
              "removed": false,
              "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                "0x00000000000000000000000081839e7bccdc7d5f50419bc34209d8ae5969ef66",
                "0x000000000000000000000000fb3b3134f13ccd2c81f4012e53024e8135d58fee"
              ],
              "transactionHash": "0x344797609db13153fd3c1c23529d7e7b794ddd586d3b6c53dc20fb2343ae3ee4",
              "transactionIndex": "0x0"
            },
            {
              "address": "0xfb3b3134f13ccd2c81f4012e53024e8135d58fee",
              "blockHash": "0x718c2a920c27f6716f04d73677eeaf31a7faec1cd585b86aa7de8678e8559172",
              "blockNumber": "0x4070e93",
              "blockTimestamp": "0x6a0c7912",
              "data": "0x0000000000000000000000000000000000000000000000000000000005f5e100",
              "logIndex": "0x2",
              "removed": false,
              "topics": [
                "0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c",
                "0x00000000000000000000000081839e7bccdc7d5f50419bc34209d8ae5969ef66"
              ],
              "transactionHash": "0x344797609db13153fd3c1c23529d7e7b794ddd586d3b6c53dc20fb2343ae3ee4",
              "transactionIndex": "0x0"
            },
            {
              "address": "0xfb3b3134f13ccd2c81f4012e53024e8135d58fee",
              "blockHash": "0x718c2a920c27f6716f04d73677eeaf31a7faec1cd585b86aa7de8678e8559172",
              "blockNumber": "0x4070e93",
              "blockTimestamp": "0x6a0c7912",
              "data": "0x0000000000000000000000000000000000000000000000000000000005f5e100",
              "logIndex": "0x3",
              "removed": false,
              "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                "0x00000000000000000000000081839e7bccdc7d5f50419bc34209d8ae5969ef66",
                "0x0000000000000000000000006af7a2b30e6e90f6907b440aebe6c7f5cb82f321"
              ],
              "transactionHash": "0x344797609db13153fd3c1c23529d7e7b794ddd586d3b6c53dc20fb2343ae3ee4",
              "transactionIndex": "0x0"
            },
            {
              "address": "0xeca9bc828a3005b9a3b909f2cc5c2a54794de05f",
              "blockHash": "0x718c2a920c27f6716f04d73677eeaf31a7faec1cd585b86aa7de8678e8559172",
              "blockNumber": "0x4070e93",
              "blockTimestamp": "0x6a0c7912",
              "data": "0x0000000000000000000000000000000000000000000000000000000006e68b71",
              "logIndex": "0x4",
              "removed": false,
              "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                "0x0000000000000000000000006af7a2b30e6e90f6907b440aebe6c7f5cb82f321",
                "0x00000000000000000000000093a8ec1d0698a3873e942a4e3b65a6c20f7310d3"
              ],
              "transactionHash": "0x344797609db13153fd3c1c23529d7e7b794ddd586d3b6c53dc20fb2343ae3ee4",
              "transactionIndex": "0x0"
            },
            {
              "address": "0x6af7a2b30e6e90f6907b440aebe6c7f5cb82f321",
              "blockHash": "0x718c2a920c27f6716f04d73677eeaf31a7faec1cd585b86aa7de8678e8559172",
              "blockNumber": "0x4070e93",
              "blockTimestamp": "0x6a0c7912",
              "data": "0x000000000000000000000000000000000000000000000000000007476c37f06900000000000000000000000000000000000000000000000000000644c0da4fa5",
              "logIndex": "0x5",
              "removed": false,
              "topics": [
                "0x1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1"
              ],
              "transactionHash": "0x344797609db13153fd3c1c23529d7e7b794ddd586d3b6c53dc20fb2343ae3ee4",
              "transactionIndex": "0x0"
            },
            {
              "address": "0x6af7a2b30e6e90f6907b440aebe6c7f5cb82f321",
              "blockHash": "0x718c2a920c27f6716f04d73677eeaf31a7faec1cd585b86aa7de8678e8559172",
              "blockNumber": "0x4070e93",
              "blockTimestamp": "0x6a0c7912",
              "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005f5e1000000000000000000000000000000000000000000000000000000000006e68b710000000000000000000000000000000000000000000000000000000000000000",
              "logIndex": "0x6",
              "removed": false,
              "topics": [
                "0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822",
                "0x00000000000000000000000081839e7bccdc7d5f50419bc34209d8ae5969ef66",
                "0x00000000000000000000000093a8ec1d0698a3873e942a4e3b65a6c20f7310d3"
              ],
              "transactionHash": "0x344797609db13153fd3c1c23529d7e7b794ddd586d3b6c53dc20fb2343ae3ee4",
              "transactionIndex": "0x0"
            }
          ],
          "returnData": "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000005f5e1000000000000000000000000000000000000000000000000000000000006e68b71",
          "status": "0x1",
          "transactionHash": "0x344797609db13153fd3c1c23529d7e7b794ddd586d3b6c53dc20fb2343ae3ee4",
          "transactionIndex": "0x0"
        }
      ],
      "difficulty": "0x0",
      "extraData": "0x",
      "gasLimit": "0x5f5e100",
      "gasUsed": "0x1848c",
      "hash": "0x718c2a920c27f6716f04d73677eeaf31a7faec1cd585b86aa7de8678e8559172",
      "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "miner": "0x0000000000000000000000000000000000000000",
      "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "nonce": "0x0000000000000000",
      "number": "0x4070e93",
      "parentHash": "0x0000000004070e92faddcad7527771849166dfe418c1fd3ef3dc1bebf3937956",
      "receiptsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "sha3Uncles": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "size": "0x0",
      "stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "timestamp": "0x6a0c7913",
      "totalDifficulty": "0x0",
      "transactions": [
        "0x344797609db13153fd3c1c23529d7e7b794ddd586d3b6c53dc20fb2343ae3ee4"
      ],
      "transactionsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "uncles": []
    }
  ]
}

// multiple calls in one request, second call reverted, calls depend on state (Wrap 5 TRX to WTRX, try to unwrap 5.000001 TRX (error), try to unwrap 5 TRX (success))
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_simulateV1",
  "params": [
    {
      "blockStateCalls": [
        {
          "calls": [
            {
              "from": "0x93a8ec1D0698a3873E942A4e3b65A6c20F7310d3",
              "to": "0xfb3b3134F13CcD2C81F4012E53024e8135d58FeE",
              "data": "0xd0e30db0",
              "value": "0x4C4B40"
            },
            {
              "from": "0x93a8ec1D0698a3873E942A4e3b65A6c20F7310d3",
              "to": "0xfb3b3134F13CcD2C81F4012E53024e8135d58FeE",
              "data": "0x2e1a7d4d00000000000000000000000000000000000000000000000000000000004C4B41",
              "value": "0x0"
            },
            {
              "from": "0x93a8ec1D0698a3873E942A4e3b65A6c20F7310d3",
              "to": "0xfb3b3134F13CcD2C81F4012E53024e8135d58FeE",
              "data": "0x2e1a7d4d00000000000000000000000000000000000000000000000000000000004C4B40",
              "value": "0x0"
            }
          ]
        }
      ],
      "traceTransfers": true,
      "returnFullTransactions": false
    },
    "latest"
  ]
}

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    {
      "baseFeePerGas": "0x0",
      "calls": [
        {
          "contractAddress": "0xfb3b3134f13ccd2c81f4012e53024e8135d58fee",
          "gasUsed": "0x5538",
          "logs": [
            {
              "address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
              "blockHash": "0x5bfb602ccdeff58b0fbd7efba7329316c19acaf0fa07cb46a388348479712ec5",
              "blockNumber": "0x4070efd",
              "blockTimestamp": "0x6a0c7a4f",
              "data": "0x00000000000000000000000000000000000000000000000000000000004c4b40",
              "logIndex": "0x0",
              "removed": false,
              "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                "0x00000000000000000000000093a8ec1d0698a3873e942a4e3b65a6c20f7310d3",
                "0x000000000000000000000000fb3b3134f13ccd2c81f4012e53024e8135d58fee"
              ],
              "transactionHash": "0x851bf70c374fd30c8f8ed82042735b3fe5b8fb1e2a7eb6c2a887b970b08b7cf3",
              "transactionIndex": "0x0"
            },
            {
              "address": "0xfb3b3134f13ccd2c81f4012e53024e8135d58fee",
              "blockHash": "0x5bfb602ccdeff58b0fbd7efba7329316c19acaf0fa07cb46a388348479712ec5",
              "blockNumber": "0x4070efd",
              "blockTimestamp": "0x6a0c7a4f",
              "data": "0x00000000000000000000000000000000000000000000000000000000004c4b40",
              "logIndex": "0x1",
              "removed": false,
              "topics": [
                "0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c",
                "0x00000000000000000000000093a8ec1d0698a3873e942a4e3b65a6c20f7310d3"
              ],
              "transactionHash": "0x851bf70c374fd30c8f8ed82042735b3fe5b8fb1e2a7eb6c2a887b970b08b7cf3",
              "transactionIndex": "0x0"
            }
          ],
          "returnData": "0x",
          "status": "0x1",
          "transactionHash": "0x851bf70c374fd30c8f8ed82042735b3fe5b8fb1e2a7eb6c2a887b970b08b7cf3",
          "transactionIndex": "0x0"
        },
        {
          "errorMessage": "REVERT opcode executed",
          "gasUsed": "0x206",
          "logs": [],
          "returnData": "0x",
          "status": "0x0",
          "transactionHash": "0x5bfb602ccdeff58b0fbd7efba7329316c19acaf0fa07cb46a388348479712ec5",
          "transactionIndex": "0x1"
        },
        {
          "contractAddress": "0xfb3b3134f13ccd2c81f4012e53024e8135d58fee",
          "gasUsed": "0x3697",
          "logs": [
            {
              "address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
              "blockHash": "0x5bfb602ccdeff58b0fbd7efba7329316c19acaf0fa07cb46a388348479712ec5",
              "blockNumber": "0x4070efd",
              "blockTimestamp": "0x6a0c7a4f",
              "data": "0x00000000000000000000000000000000000000000000000000000000004c4b40",
              "logIndex": "0x2",
              "removed": false,
              "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                "0x000000000000000000000000fb3b3134f13ccd2c81f4012e53024e8135d58fee",
                "0x00000000000000000000000093a8ec1d0698a3873e942a4e3b65a6c20f7310d3"
              ],
              "transactionHash": "0x5f1ddb59ccbb4bae0db5418018e2a17b89f0c9aaba824bf22197278b677fb982",
              "transactionIndex": "0x2"
            },
            {
              "address": "0xfb3b3134f13ccd2c81f4012e53024e8135d58fee",
              "blockHash": "0x5bfb602ccdeff58b0fbd7efba7329316c19acaf0fa07cb46a388348479712ec5",
              "blockNumber": "0x4070efd",
              "blockTimestamp": "0x6a0c7a4f",
              "data": "0x00000000000000000000000000000000000000000000000000000000004c4b40",
              "logIndex": "0x3",
              "removed": false,
              "topics": [
                "0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65",
                "0x00000000000000000000000093a8ec1d0698a3873e942a4e3b65a6c20f7310d3"
              ],
              "transactionHash": "0x5f1ddb59ccbb4bae0db5418018e2a17b89f0c9aaba824bf22197278b677fb982",
              "transactionIndex": "0x2"
            }
          ],
          "returnData": "0x",
          "status": "0x1",
          "transactionHash": "0x5f1ddb59ccbb4bae0db5418018e2a17b89f0c9aaba824bf22197278b677fb982",
          "transactionIndex": "0x2"
        }
      ],
      "difficulty": "0x0",
      "extraData": "0x",
      "gasLimit": "0x5f5e100",
      "gasUsed": "0x8dd5",
      "hash": "0x5bfb602ccdeff58b0fbd7efba7329316c19acaf0fa07cb46a388348479712ec5",
      "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "miner": "0x0000000000000000000000000000000000000000",
      "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "nonce": "0x0000000000000000",
      "number": "0x4070efd",
      "parentHash": "0x0000000004070efce9ab496dd918acc8efb66ef8fec03290ff59510b8286dc91",
      "receiptsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "sha3Uncles": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "size": "0x0",
      "stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "timestamp": "0x6a0c7a51",
      "totalDifficulty": "0x0",
      "transactions": [
        "0x851bf70c374fd30c8f8ed82042735b3fe5b8fb1e2a7eb6c2a887b970b08b7cf3",
        "0x5bfb602ccdeff58b0fbd7efba7329316c19acaf0fa07cb46a388348479712ec5",
        "0x5f1ddb59ccbb4bae0db5418018e2a17b89f0c9aaba824bf22197278b677fb982"
      ],
      "transactionsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "uncles": []
    }
  ]
}

@APshenkin APshenkin changed the title implement eth_simulateV1 JSON-RPC method for trading-flow case feat(jsonrpc): implement eth_simulateV1 JSON-RPC method for trading-flow case May 19, 2026
@APshenkin APshenkin changed the title feat(jsonrpc): implement eth_simulateV1 JSON-RPC method for trading-flow case feat(jsonrpc): implement base eth_simulateV1 JSON-RPC method May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Support for eth_simulateV1 Method in Tron JSON-RPC

1 participant