Skip to content
This repository was archived by the owner on Jun 3, 2022. It is now read-only.
This repository was archived by the owner on Jun 3, 2022. It is now read-only.

eth_simulateTransaction #8

@kumavis

Description

@kumavis

summary

eth_simulateTransaction should be introduced to replace eth_call and eth_estimateGas

eth_simulateTransaction can provide information including:

  • return value
  • gas consumption
  • if an error was thrown

This helps solve the problem of trying to differentiate between correct response and error response with eth_call and eth_estimateGas

spec

eth_simulateTransaction

Executes a new message call without creating a transaction on the block chain.

Parameters
  1. Object - The transaction call object
  • from: DATA, 20 Bytes - (optional) The address the transaction is sent from.
  • to: DATA, 20 Bytes - The address the transaction is directed to.
  • gas: QUANTITY - (optional) Integer of the gas provided for the transaction execution. eth_call consumes zero gas, but this parameter may be needed by some executions.
  • gasPrice: QUANTITY - (optional) Integer of the gasPrice used for each paid gas
  • value: QUANTITY - (optional) Integer of the value send with this transaction
  • data: DATA - (optional) Hash of the method signature and encoded parameters. For details see Ethereum Contract ABI
  1. QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the default block parameter
Returns

Object - A transaction summary object

  • returnValue: DATA, 32 Bytes - hash of the transaction.
  • gasUsed : QUANTITY - The amount of gas used by this specific transaction alone.
  • contractAddress : DATA, 20 Bytes - The contract address created, if the transaction was a contract creation, otherwise null.
  • logs: Array - Array of log objects, which this transaction generated.
  • errorCode: null or string - (needs spec) Whether or not an error such as a top-level OOG, invalid jump, or other vm-halting error occurred. Code should indicate the status in this way:
    • (successful)
    • out of gas
    • stack overflow
    • stack underflow
    • invalid jump (no JUMPDEST present)
    • invalid instruction
    • possibly the INVALID instruction could have its own code
    • stop by REVERT
Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_simulateTransaction","params":[{"to": "0xCD111aa492a9c77a367C36E6D6AF8e6f212E0C8E"}],"id":1}'

// Result
{
  "id":1,
  "jsonrpc": "2.0",
  "result": {
    "returnValue": "0x4242",
    "gasUsed": "0x5208",
    "contractAddress": null,
    "logs": [],
    "errorCode": null
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions