Ganache Ethereum JSON-RPC documentation.
Returns the kademlia table in a readable table format.
Promise<any[]>
: Returns the kademlia table in a readable table format.
Returns details about the swarm node.
Promise<any[]>
: Returns details about the swarm node.
Returns binary data from the local database.
dbName: string
: Database name.key: string
: Key name.
Promise<string>
: The previously stored data.
Returns string from the local database.
dbName: string
: Database name.key: string
: Key name.
Promise<string>
: The previously stored string.
Stores binary data in the local database.
dbName: string
: Database name.key: string
: Key name.data: DATA
: Data to store.
Promise<boolean>
: true if the value was stored, otherwise false.
Stores a string in the local database.
dbName: string
: Database name.key: string
: Key name.value: string
: String to store.
Promise<boolean>
: returns true if the value was stored, otherwise false.
Attempts to replay the transaction as it was executed on the network and return storage data given a starting key and max number of entries to return.
blockHash: DATA
: Hash of a block.transactionIndex: number
: Integer of the transaction index position.contractAddress: DATA
: Address of the contract.startKey: DATA
: Hash of the start key for grabbing storage entries.maxResult: number
: Integer of maximum number of storage entries to return.
Promise<Ethereum.StorageRangeResult>
: Returns a storage object with the keys being keccak-256 hashes of the storage keys, and the values being the raw, unhashed key and value for that specific storage slot. Also returns a next key which is the keccak-256 hash of the next key in storage for continuous downloading.
Attempt to run the transaction in the exact same manner as it was executed on the network. It will replay any transaction that may have been executed prior to this one before it will finally attempt to execute the transaction that corresponds to the given hash.
transactionHash: DATA
: Hash of the transaction to trace.options?: Ethereum.TransactionTraceOptions
: See options in source.
Promise<Ethereum.TraceTransactionResult>
: Returns the gas
, structLogs
, and returnValue
for the traced transaction. The structLogs
are an array of logs, which contains the following fields:
depth
: The execution depth.error
: Information about an error, if one occurred.gas
: The number of gas remaining.gasCost
: The cost of gas in wei.memory
: An array containing the contract's memory data.op
: The current opcode.pc
: The current program counter.stack
: The EVM execution stack.storage
: An object containing the contract's storage data.
Returns a list of addresses owned by client.
Promise<string[]>
: Array of 20 Bytes - addresses owned by the client.
Returns the number of the most recent block.
Promise<QUANTITY>
: The current block number the client is on.
Executes a new message call immediately without creating a transaction on the block chain.
-
transaction: any
: The transaction call object as seen in source. -
blockNumber: QUANTITY | TAG
: Integer block number, or the string "latest", "earliest" or "pending". -
overrides: CallOverrides
: State overrides to apply during the simulation.-
CallOverrides
- An address-to-state mapping, where each entry specifies some state to be ephemerally overridden prior to executing the call. Each address maps to an object containing: -balance: QUANTITY
(optional) - The balance to set for the account before executing the call. -nonce: QUANTITY
(optional) - The nonce to set for the account before executing the call. -code: DATA
(optional) - The EVM bytecode to set for the account before executing the call. -state: OBJECT
(optional*) - Key-value mapping to override all slots in the account storage before executing the call. -stateDiff: OBJECT
(optional*) - Key-value mapping to override individual slots in the account storage before executing the call._\*Note - `state` and `stateDiff` fields are mutually exclusive._
-
Promise<DATA>
: The return value of executed contract.
Returns the currently configured chain id, a value used in replay-protected transaction signing as introduced by EIP-155.
Promise<QUANTITY>
: The chain id as a string.
Returns the client coinbase address.
Promise<Address>
: The current coinbase address.
Generates and returns an estimate of how much gas is necessary to allow the transaction to complete. The transaction will not be added to the blockchain. Note that the estimate may be significantly more than the amount of gas actually used by the transaction, for a variety of reasons including EVM mechanics and node performance.
transaction: Ethereum.Transaction
: The transaction call object as seen in source.blockNumber: QUANTITY | TAG
: Integer block number, or the string "latest", "earliest" or "pending".
Promise<QUANTITY>
: The amount of gas used.
Returns the current price per gas in wei.
Promise<QUANTITY>
: Integer of the current gas price in wei.
Returns the balance of the account of given address.
address: DATA
: Address to check for balance.blockNumber: QUANTITY | TAG
: Integer block number, or the string "latest", "earliest" or "pending".
Promise<QUANTITY>
: Integer of the account balance in wei.
Returns information about a block by block hash.
hash: DATA
: Hash of a block.transactions: boolean
: Iftrue
it returns the full transaction objects, iffalse
only the hashes of the transactions.
Promise<Ethereum.Block<IncludeTransactions>>
: The block, null
if the block doesn't exist.
Returns information about a block by block number.
number: QUANTITY | TAG
: Integer of a block number, or the string "earliest", "latest" or "pending", as in the default block parameter.transactions: boolean
: Iftrue
it returns the full transaction objects, iffalse
only the hashes of the transactions.
Promise<Ethereum.Block<IncludeTransactions>>
: The block, null
if the block doesn't exist.
Returns the number of transactions in a block from a block matching the given block hash.
hash: DATA
: Hash of a block.
Promise<QUANTITY>
: Number of transactions in the block.
Returns the number of transactions in a block from a block matching the given block number.
blockNumber: QUANTITY | TAG
Promise<QUANTITY>
: Integer of the number of transactions in the block.
Returns code at a given address.
address: DATA
: Address.blockNumber: QUANTITY | TAG
: Integer block number, or the string "latest", "earliest" or "pending".
Promise<DATA>
: The code from the given address.
Returns a list of available compilers.
Promise<string[]>
: List of available compilers.
Polling method for a filter, which returns an array of logs, block hashes, or transaction hashes, depending on the filter type, which occurred since last poll.
filterId: QUANTITY
: The filter id.
Promise<DATA[]>
: An array of logs, block hashes, or transaction hashes, depending on the filter type, which occurred since last poll. For filters created with eth_newBlockFilter
the return are block hashes (DATA
, 32 Bytes). For filters created with eth_newPendingTransactionFilter
the return are transaction hashes (DATA
, 32 Bytes). For filters created with eth_newFilter
the return are log objects with the following parameters:
removed
:TAG
-true
when the log was removed,false
if its a valid log.logIndex
:QUANTITY
- Integer of the log index position in the block.null
when pending.transactionIndex
:QUANTITY
- Integer of the transactions index position.null
when pending.transactionHash
:DATA
, 32 Bytes - Hash of the transaction where the log was.null
when pending.blockHash
:DATA
, 32 Bytes - Hash of the block where the log was.null
when pending.blockNumber
:QUANTITY
- The block number where the log was in.null
when pending.address
:DATA
, 20 Bytes - The address from which the log originated.data
:DATA
- Contains one or more 32 Bytes non-indexed arguments of the log.topics
:Array of DATA
- Array of 0 to 4 32 BytesDATA
of indexed log arguments.
Returns an array of all logs matching filter with given id.
filterId: QUANTITY
: The filter id.
Promise<object[]>
: Array of log objects, or an empty array.
Returns an array of all logs matching a given filter object.
filter: Ethereum.LogsFilter
: The filter options as seen in source.
Promise<object[]>
: Array of log objects, or an empty array.
Returns the value from a storage position at a given address.
address: DATA
: Address of the storage.position: QUANTITY
: Integer of the position in the storage.blockNumber: QUANTITY | TAG
: Integer block number, or the string "latest", "earliest" or "pending".
Promise<DATA>
: The value in storage at the requested position.
Returns information about a transaction by block hash and transaction index position.
hash: DATA
: Hash of a block.index: QUANTITY
: Integer of the transaction index position.
Promise<object>
: The transaction object or null
if no transaction was found.
Returns information about a transaction by block number and transaction index position.
number: QUANTITY | TAG
: A block number, or the string "earliest", "latest" or "pending".index: QUANTITY
: Integer of the transaction index position.
Promise<object>
: The transaction object or null
if no transaction was found.
Returns the information about a transaction requested by transaction hash.
transactionHash: DATA
: Hash of a transaction.
Promise<object>
: The transaction object or null
if no transaction was found.
Returns the number of transactions sent from an address.
address: DATA
:DATA
, 20 Bytes - The address to get number of transactions sent fromblockNumber: QUANTITY | TAG
: Integer block number, or the string "latest", "earliest" or "pending".
Promise<QUANTITY>
: Number of transactions sent from this address.
Returns the receipt of a transaction by transaction hash.
transactionHash: DATA
: Hash of a transaction.
Promise<Ethereum.TransactionReceipt>
: Returns the receipt of a transaction by transaction hash.
Returns information about a uncle of a block by hash and uncle index position.
hash: DATA
: Hash of a block.index: QUANTITY
: The uncle's index position.
Promise<object>
: A block object or null
when no block is found.
Returns information about a uncle of a block by hash and uncle index position.
blockNumber: QUANTITY | TAG
: A block number, or the string "earliest", "latest" or "pending".uncleIndex: QUANTITY
: The uncle's index position.
Promise<object>
: A block object or null
when no block is found.
Returns the number of uncles in a block from a block matching the given block hash.
hash: DATA
: Hash of a block.
Promise<QUANTITY>
: The number of uncles in a block.
Returns the number of uncles in a block from a block matching the given block hash.
blockNumber: QUANTITY | TAG
: A block number, or the string "earliest", "latest" or "pending".
Promise<QUANTITY>
: The number of uncles in a block.
Returns: An Array with the following elements:
DATA
, 32 Bytes - current block header pow-hashDATA
, 32 Bytes - the seed hash used for the DAG.DATA
, 32 Bytes - the boundary condition ("target"), 2^256 / difficulty.
Promise<[] | [string, string, string]>
: The hash of the current block, the seedHash, and the boundary condition to be met ("target").
Returns the number of hashes per second that the node is mining with.
Promise<QUANTITY>
: Number of hashes per second.
Returns a maxPriorityFeePerGas
value suitable for quick transaction inclusion.
Promise<QUANTITY>
: The maxPriorityFeePerGas in wei.
Returns true
if client is actively mining new blocks.
Promise<boolean>
: returns true
if the client is mining, otherwise false
.
Creates a filter in the node, to notify when a new block arrives. To check if the state has changed, call eth_getFilterChanges
.
Promise<QUANTITY>
: A filter id.
Creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call eth_getFilterChanges
.
filter?: Ethereum.Filter
: The filter options as seen in source.
Promise<QUANTITY>
: A filter id.
Creates a filter in the node, to notify when new pending transactions arrive. To check if the state has changed, call eth_getFilterChanges
.
Promise<QUANTITY>
: A filter id.
Returns the current ethereum protocol version.
Promise<DATA>
: The current ethereum protocol version.
Creates new message call transaction or a contract creation for signed transactions.
transaction: string
: The signed transaction data.
Promise<DATA>
: The transaction hash.
Creates new message call transaction or a contract creation, if the data field contains code.
transaction: Ethereum.Transaction
: The transaction call object as seen in source.
Promise<DATA>
: The transaction hash.
The sign method calculates an Ethereum specific signature with: sign(keccak256("\x19Ethereum Signed Message:\n" + message.length + message)))
.
address: DATA
: Address to sign with.message: DATA
: Message to sign.
Promise<string>
: Signature - a hex encoded 129 byte array starting with 0x
. It encodes the r
, s
, and v
parameters from appendix F of the yellow paper in big-endian format. Bytes 0...64 contain the r
parameter, bytes 64...128 the s
parameter, and the last byte the v
parameter. Note that the v
parameter includes the chain id as specified in EIP-155.
Signs a transaction that can be submitted to the network at a later time using eth_sendRawTransaction
.
transaction: Ethereum.Transaction
: The transaction call object as seen in source.
Promise<string>
: The raw, signed transaction.
Identical to eth_signTypedData_v4.
address: DATA
: Address of the account that will sign the messages.typedData: Ethereum.TypedData
: Typed structured data to be signed.
Promise<string>
: Signature. As in eth_sign
, it is a hex encoded 129 byte array starting with 0x
. It encodes the r
, s
, and v
parameters from appendix F of the yellow paper in big-endian format. Bytes 0...64 contain the r
parameter, bytes 64...128 the s
parameter, and the last byte the v
parameter. Note that the v
parameter includes the chain id as specified in EIP-155.
address: DATA
: Address of the account that will sign the messages.typedData: Ethereum.TypedData
: Typed structured data to be signed.
Promise<string>
: Signature. As in eth_sign
, it is a hex encoded 129 byte array starting with 0x
. It encodes the r
, s
, and v
parameters from appendix F of the yellow paper in big-endian format. Bytes 0...64 contain the r
parameter, bytes 64...128 the s
parameter, and the last byte the v
parameter. Note that the v
parameter includes the chain id as specified in [EIP-155](https://eips.ethereum.org/EIPS/eip-155).
Used for submitting mining hashrate.
hashRate: DATA
: A hexadecimal string representation (32 bytes) of the hash rate.clientID: DATA
: A random hexadecimal(32 bytes) ID identifying the client.
Promise<boolean>
: true
if submitting went through succesfully and false
otherwise.
Used for submitting a proof-of-work solution.
nonce: DATA
: The nonce found (64 bits).powHash: DATA
: The header's pow-hash (256 bits).digest: DATA
: The mix digest (256 bits).
Promise<boolean>
: true
if the provided solution is valid, otherwise false
.
Starts a subscription to a particular event. For every event that matches the subscription a JSON-RPC notification with event details and subscription ID will be sent to a client.
subscriptionName: Ethereum.SubscriptionName
: Name for the subscription.
PromiEvent<QUANTITY>
: A subscription id.
Returns an object containing data about the sync status or false
when not syncing.
Promise<object>
: An object with sync status data or false
, when not syncing.
Uninstalls a filter with given id. Should always be called when watch is no longer needed.
filterId: QUANTITY
: The filter id.
Promise<boolean>
: true
if the filter was successfully uninstalled, otherwise false
.
Cancel a subscription to a particular event. Returns a boolean indicating if the subscription was successfully cancelled.
subscriptionId: Ethereum.SubscriptionId
: The ID of the subscription to unsubscribe to.
Promise<boolean>
: true
if subscription was cancelled successfully, otherwise false
.
Adds any arbitrary account to the personal
namespace.
address: DATA
: The address of the account to add to thepersonal
namespace.passphrase: string
: The passphrase used to encrypt the account's private key. NOTE: this passphrase will be needed for allpersonal
namespace calls that require a password.
Promise<boolean>
: true
if the account was successfully added. false
if the account is already in the personal
namespace.
Jump forward in time by the given amount of time, in seconds.
seconds: number | QUANTITY
: Number of seconds to jump forward in time by. Must be greater than or equal to0
.
Promise<number>
: Returns the total time adjustment, in seconds.
Force a single block to be mined.
timestamp: number
: the timestamp the block should be mined with. EXPERIMENTAL: Optionally, specify anoptions
object withtimestamp
and/orblocks
fields. Ifblocks
is given, it will mine exactlyblocks
number of blocks, regardless of any other blocks mined or reverted during it's operation. This behavior is subject to change!
Promise<"0x0">
: The string "0x0"
. May return additional meta-data in the future.
Removes an account from the personal
namespace.
address: DATA
: The address of the account to remove from thepersonal
namespace.passphrase: string
: The passphrase used to decrypt the account's private key.
Promise<boolean>
: true
if the account was successfully removed. false
if the account was not in the personal
namespace.
Revert the state of the blockchain to a previous snapshot. Takes a single parameter, which is the snapshot id to revert to. This deletes the given snapshot, as well as any snapshots taken after (e.g.: reverting to id 0x1 will delete snapshots with ids 0x1, 0x2, etc.)
snapshotId: QUANTITY
: The snapshot id to revert.
Promise<boolean>
: true
if a snapshot was reverted, otherwise false
.
Sets the given account's nonce to the specified value. Mines a new block before returning.
address: DATA
: The account address to update.nonce: QUANTITY
: The nonce value to be set.
Promise<boolean>
: true
if it worked, otherwise false
.
Sets the given account's balance to the specified WEI value. Mines a new block before returning.
address: DATA
: The account address to update.balance: QUANTITY
: The balance value, in WEI, to be set.
Promise<boolean>
: true
if it worked, otherwise false
.
Sets the given account's code to the specified value. Mines a new block before returning.
address: DATA
: The account address to update.code: DATA
: The code to be set.
Promise<boolean>
: true
if it worked, otherwise false
.
Sets the given account's storage slot to the specified data. Mines a new block before returning.
address: DATA
: The account address to update.slot: DATA
: The storage slot that should be set.value: DATA
: The value to be set.
Promise<boolean>
: true
if it worked, otherwise false
.
Sets the internal clock time to the given timestamp.
time: number | QUANTITY | Date
: JavaScript timestamp (millisecond precision).
Promise<number>
: The amount of seconds between the given timestamp and now.
Snapshot the state of the blockchain at the current block. Takes no parameters. Returns the id of the snapshot that was created. A snapshot can only be reverted once. After a successful evm_revert
, the same snapshot id cannot be used again. Consider creating a new snapshot after each evm_revert
if you need to revert to the same point multiple times.
Promise<QUANTITY>
: The hex-encoded identifier for this snapshot.
Sets the etherbase, where mining rewards will go.
address: DATA
: The address where the mining rewards will go.
Promise<boolean>
: true
.
Set the extraData block header field a miner can include.
extra: DATA
: TheextraData
to include.
Promise<boolean>
: If successfully set returns true
, otherwise returns an error.
Sets the default accepted gas price when mining transactions. Any transactions that don't specify a gas price will use this amount. Transactions that are below this limit are excluded from the mining process.
number: QUANTITY
: Default accepted gas price.
Promise<boolean>
: true
.
Resume the CPU mining process with the given number of threads.
threads: number
: Number of threads to resume the CPU mining process with.
Promise<boolean>
: true
.
Stop the CPU mining operation.
Promise<boolean>
: true
.
Returns true
if client is actively listening for network connections.
Promise<boolean>
: true
when listening, otherwise false
.
Returns number of peers currently connected to the client.
Promise<QUANTITY>
: Number of connected peers.
Returns the current network id.
Promise<string>
: The current network id. This value should NOT be JSON-RPC Quantity/Data encoded.
Imports the given unencrypted private key (hex string) into the key store, encrypting it with the passphrase.
rawKey: DATA
: The raw, unencrypted private key to import.passphrase: string
: The passphrase to encrypt with.
Promise<Address>
: Returns the address of the new account.
Returns all the Ethereum account addresses of all keys that have been added.
Promise<string[]>
: The Ethereum account addresses of all keys that have been added.
Locks the account. The account can no longer be used to send transactions.
address: DATA
: The account address to be locked.
Promise<boolean>
: Returns true
if the account was locked, otherwise false
.
Generates a new account with private key. Returns the address of the new account.
passphrase: string
: The passphrase to encrypt the private key with.
Promise<Address>
: The new account's address.
Validate the given passphrase and submit transaction.
transaction: Ethereum.Transaction
passphrase: string
: The passphrase to decrypt the private key belonging totx.from
.
Promise<DATA>
: The transaction hash or if unsuccessful an error.
Validates the given passphrase and signs a transaction that can be submitted to the network at a later time using eth_sendRawTransaction
.
transaction: Ethereum.Transaction
: The transaction call object as seen in source.passphrase: string
Promise<string>
: The raw, signed transaction.
Unlocks the account for use.
address: DATA
: 20 Bytes - The address of the account to unlock.passphrase: string
: Passphrase to unlock the account.duration: number
: (default: 300) Duration in seconds how long the account should remain unlocked for. Set to 0 to disable automatic locking.
Promise<boolean>
: true
if it worked. Throws an error or returns false
if it did not.
Returns object of RPC modules.
Promise<object>
: RPC modules.
Adds a whisper identity to the group.
address: DATA
: The identity address to add to a group.
Promise<boolean>
: true
if the identity was successfully added to the group, otherwise false
.
Polling method for whisper filters. Returns new messages since the last call of this method.
id: QUANTITY
: The filter id. Ex: "0x7"
Promise<any[]>
: More Info: https://github.com/ethereum/wiki/wiki/JSON-RPC#shh\_getfilterchanges
Get all messages matching a filter. Unlike shh_getFilterChanges this returns all messages.
id: QUANTITY
: The filter id. Ex: "0x7"
Promise<boolean>
: See: shh_getFilterChanges
.
Checks if the client hold the private keys for a given identity.
address: DATA
: The identity address to check.
Promise<boolean>
: Returns true
if the client holds the private key for that identity, otherwise false
.
Creates filter to notify, when client receives whisper message matching the filter options.
to: DATA
: (optional) Identity of the receiver. When present it will try to decrypt any incoming message if the client holds the private key to this identity.topics: DATA[]
: Array of topics which the incoming message's topics should match.
Promise<boolean>
: Returns true
if the identity was successfully added to the group, otherwise false
.
Creates a new group.
Promise<string>
: The address of the new group.
Creates new whisper identity in the client.
Promise<string>
: - The address of the new identity.
Creates a whisper message and injects it into the network for distribution.
postData: Ethereum.WhisperPostObject
Promise<boolean>
: Returns true
if the message was sent, otherwise false
.
Uninstalls a filter with given id. Should always be called when watch is no longer needed. Additionally filters timeout when they aren't requested with shh_getFilterChanges
for a period of time.
id: QUANTITY
: The filter id. Ex: "0x7"
Promise<boolean>
: true
if the filter was successfully uninstalled, otherwise false
.
Returns the current whisper protocol version.
Promise<string>
: The current whisper protocol version.
Returns the current content of the transaction pool.
Promise<Ethereum.Pool.Content>
: The transactions currently pending or queued in the transaction pool.
Returns the current client version.
Promise<string>
: The current client version.
Returns Keccak-256 (not the standardized SHA3-256) of the given data.
data: DATA
: the data to convert into a SHA3 hash.
Promise<DATA>
: The SHA3 result of the given string.