Transaction
eth_call
Executes a new message call immediately, without creating a transaction on the block chain. The eth_call method can be used to query internal contract state, to execute validations coded into a contract or even to test what the effect of a transaction would be without running it live.
Parameters
callObject
Object
The transaction call object. See the next table for the object's properties.
blockNumberOrTag
QUANTITY | TAG
stateOverrideSet
Object
The state override set is an optional address-to-state mapping, where each entry specifies some state to be ephemerally overridden prior to executing the call.
callObject
has the following properties:
from
20-byte DATA
(optional) Address the transaction is simulated to have been sent from. The 0x00..0
address is used if no address is specified.
to
20-byte DATA
(optional) Address the transaction is sent to.
gas
QUANTITY
(optional) Maximum gas allowance for the code execution to avoid infinite loops. Defaults to 2^63 or whatever value the node operator specified via --rpc.gascap.
gasPrice
QUANTITY
(optional) Number of peb
to simulate paying for each unit of gas during execution. Defaults to 0
peb.
value
QUANTITY
(optional) Amount of peb
to simulate sending along with the transaction. Defaults to 0
.
input
DATA
(optional) Hash of the method signature and encoded parameter. It replaces data
field, but 'data` field is still supported for backward compatibility.
Example - callObject
stateOverrideSet
has the following properties:
balance
Quantity
(optional) Fake balance to set for the account before executing the call.
nonce
Quantity
(optional) Fake nonce to set for the account before executing the call.
code
DATA
(optional) Fake EVM bytecode to inject into the account before executing the call.
state
Object
(optional) Fake key-value mapping to override all slots in the account storage before executing the call.
stateDiff
Object
(optional) Fake key-value mapping to override individual slots in the account storage before executing the call.
The goal of the state override set is manyfold:
It can be used by DApps to reduce the amount of contract code needed to be deployed on chain. Code that simply returns internal state or does pre-defined validations can be kept off chain and fed to the node on-demand.
It can be used for smart contract analysis by extending the code deployed on chain with custom methods and invoking them. This avoids having to download and reconstruct the entire state in a sandbox to run custom code against.
It can be used to debug smart contracts in an already deployed large suite of contracts by selectively overriding some code or state and seeing how execution changes. Specialized tooling will probably be necessary.
Example - stateOverrideSet
Example
To test call in meaningful way, you need to setup test environment like below.
Deploy KIP-7 Contract to test call or you can use it with already deployed one.
We will use KIP-7 contract function
totalSupply
to check whether call is working or not in this example.To call
totalSupply
you should know about its function signature which is0x18160ddd
.
In this example:
The address of KIP-7 contract:
0xbE3892d33620bE5aca8c75D39e7401871194d290
(You should use an existing contract address.)The address of caller:
0xca7a99380131e6c76cfa622396347107aeedca2d
Example - StateOverrides
Following the example above, let's test call using state overrides feature.
We will replace the bytecode of
0xbE3892d33620bE5aca8c75D39e7401871194d290
which is the address of KIP-7 contract already deployed above (Check the above example).The bytecode to be replaced is
6080604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e64cec114604e5780636057361d146076575b600080fd5b348015605957600080fd5b50606060a0565b6040518082815260200191505060405180910390f35b348015608157600080fd5b50609e6004803603810190808035906020019092919050505060a9565b005b60008054905090565b80600081905550505600a165627a7a723058207783dba41884f73679e167576362b7277f88458815141651f48ca38c25b498f80029
.The original source code of this bytecode is below.
Now let's override the state of 0xbE3892d33620bE5aca8c75D39e7401871194d290
(KIP-7 contract) with another contract's byte code (Storage contract) and call retrieve
(function signature: 0x2e64cec1
) of Storage contract.
eth_estimateGas
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.
Parameters
callObject
Object
The transaction call object. See the next table for the object's properties.
callObject
has the following properties:
from
20-byte DATA
(optional) Address the transaction is simulated to have been sent from. The 0x00..0
address is used if no address is specified.
to
20-byte DATA
(optional) Address the transaction is sent to.
gas
QUANTITY
(optional) Maximum gas allowance for the code execution to avoid infinite loops. Defaults to 2^63 or whatever value the node operator specified via --rpc.gascap.
gasPrice
QUANTITY
(optional) Number of peb
to simulate paying for each unit of gas during execution. Defaults to 0
peb.
value
QUANTITY
(optional) Amount of peb
to simulate sending along with the transaction. Defaults to 0
.
input
DATA
(optional) Hash of the method signature and encoded parameter. It replaces data
field, but 'data` field is still supported for backward compatibility.
Example - callObject
Return Value
QUANTITY
The amount of gas used.
Example
eth_getTransactionByBlockHashAndIndex
Returns information about a transaction by block hash and transaction index position.
Please check the Caution-Transaction before using this API.
Parameters
32-byte DATA
Hash of a block.
QUANTITY
Integer of the transaction index position.
Return Value
Example
To see examples of various transaction types, check eth_getTransactionByHash
eth_getTransactionByBlockNumberAndIndex
Returns information about a transaction by block number and transaction index position.
Please check the Caution-Transaction before using this API.
Parameters
QUANTITY | TAG
QUANTITY
The transaction index position.
Return Value
Example
To see examples of various transaction types, check eth_getTransactionByHash
eth_getTransactionByHash
Returns the information about a transaction requested by transaction hash.
Please check the Caution-Transaction before using this API.
Parameters
32-byte DATA
Hash of a transaction.
Return Value
Fields of transaction can be different based on transaction types. Currently, there are three types of transactions in Ethereum(Legacy, AccessList , DynamicFee).
Object
- A transaction object, or null
when no transaction was found:
Legacy Transaction
blockHash
32-byte DATA
Hash of the block where this transaction was in. null
when it is pending.
blockNumber
QUANTITY
Block number where this transaction was in. null
when it is pending.
from
20-byte DATA
Address of the sender.
gas
QUANTITY
Gas provided by the sender.
gasPrice
QUANTITY
Gas price provided by the sender in peb.
hash
32-byte DATA
Hash of the transaction.
input
DATA
The data sent along with the transaction.
nonce
QUANTITY
The number of transactions made by the sender prior to this one.
to
20-byte DATA
Address of the receiver. null
when it is a contract creation transaction.
value
QUANTITY
Integer of values sent with this transaction.
transactionIndex
QUANTITY
Integer of the transaction index position in the block. null
when it is pending.
type
QUANTITY
An integer representing the type of the transaction.
v
QUANTITY
ECDSA recovery id.
r
32-byte DATA
ECDSA signature r.
s
32-byte DATA
ECDSA signature s.
Example - Legacy Transaction
AccessList Transaction
blockHash
32-byte DATA
Hash of the block where this transaction was in. null
when it is pending.
blockNumber
QUANTITY
Block number where this transaction was in. null
when it is pending.
from
20-byte DATA
Address of the sender.
gas
QUANTITY
Gas provided by the sender.
gasPrice
QUANTITY
Gas price provided by the sender in peb.
hash
32-byte DATA
Hash of the transaction.
input
DATA
The data sent along with the transaction.
nonce
QUANTITY
The number of transactions made by the sender prior to this one.
to
20-byte DATA
Address of the receiver. null
when it is a contract creation transaction.
value
QUANTITY
Integer of values sent with this transaction.
transactionIndex
QUANTITY
Integer of the transaction index position in the block. null
when it is pending.
type
QUANTITY
An integer representing the type of the transaction.
accessList
Array
chainId
QUANTITY
Chain id set on the requested node.
v
QUANTITY
ECDSA recovery id.
r
32-byte DATA
ECDSA signature r.
s
32-byte DATA
ECDSA signature s.
Example - AccessList Transaction
DynamicFee Transaction
blockHash
32-byte DATA
Hash of the block where this transaction was in. null
when it is pending.
blockNumber
QUANTITY
Block number where this transaction was in. null
when it is pending.
from
20-byte DATA
Address of the sender.
gas
QUANTITY
Gas provided by the sender.
gasPrice
QUANTITY
Gas price provided by the sender in peb.
maxFeePerGas
QUANTITY
A maximum amount to pay for the transaction to execute.
maxPriorityFeePerGas
QUANTITY
Gas tip cap for dynamic fee transaction in peb.
hash
32-byte DATA
Hash of the transaction.
input
DATA
The data sent along with the transaction.
nonce
QUANTITY
The number of transactions made by the sender prior to this one.
to
20-byte DATA
Address of the receiver. null
when it is a contract creation transaction.
value
QUANTITY
Integer of values sent with this transaction.
transactionIndex
QUANTITY
Integer of the transaction index position in the block. null
when it is pending.
type
QUANTITY
An integer representing the type of the transaction.
accessList
Array
chainId
QUANTITY
Chain id set on the requested node.
v
QUANTITY
ECDSA recovery id.
r
32-byte DATA
ECDSA signature r.
s
32-byte DATA
ECDSA signature s.
Example - DynamicFee Transaction
eth_getTransactionReceipt
Returns the receipt of a transaction by transaction hash.
NOTE: The receipt is not available for pending transactions.
Please check the Caution-TransactionReceipt before using this API.
Parameters
Hash
32-byte DATA
Hash of a transaction.
Return Value
Object
- A transaction receipt object, or null
when no receipt was found
blockHash
32-byte DATA
Hash of the block where this transaction was in.
blockNumber
QUANTITY
The block number where this transaction was in.
contractAddress
DATA
The contract address created, if the transaction was a contract creation, otherwise null
.
cumulativeGasUsed
QUANTITY
The total amount of gas used when this transaction was executed in the block.
effectiveGasPrice
QUANTITY
The actual value per gas deducted from the senders account. Before EIP-1559, this is equal to the transaction's gas price. After, it is equal to baseFeePerGas + min(maxFeePerGas - baseFeePerGas, maxPriorityFeePerGas).
from
20-byte DATA
Address of the sender.
logs
Array
Array of log objects, which this transaction generated.
logsBloom
256-byte DATA
Bloom filter for light clients to quickly retrieve related logs.
status
QUANTITY
Either 1
(success) or 0
(failure).
to
20-byte DATA
Address of the receiver. null
when it is a contract creation transaction.
transactionHash
32-byte DATA
Hash of the transaction.
transactionIndex
QUANTITY
Integer of the transaction index position in the block.
type
QUANTITY
An integer representing the type of the transaction.
Example
eth_sendRawTransaction
Creates a new message call transaction or a contract creation for signed transactions.
Parameters
DATA
The signed transaction data.
Return Value
32-byte DATA
The transaction hash or the zero hash if the transaction is not yet available.
If you deployed a contract, use eth_getTransactionReceipt to get the contract address.
Example
eth_sendTransaction
Constructs a transaction with given parameters, signs the transaction with a sender's private key and propagates the transaction to Klaytn network.
NOTE: The address to sign with must be unlocked.
Parameters:
transactionArgs
Object
An object of transaction arguments. See the table below for the object's properties.
transactionArgs
has the following properties:
from
20-byte DATA
The address from which the transaction is sent.
to
20-byte DATA
(not required when creating a new contract) The address to which the transaction is directed.
gas
QUANTITY
(optional) The integer of the gas provided for the transaction's execution. It will return unused gas.
maxFeePerGas
QUANTITY
(optional) The maximum amount to pay for the transaction's execution.
maxPriorityFeePerGas
QUANTITY
(optional) Gas tip cap for dynamic fee transaction in peb.
input
DATA
(optional) The hash of the method signature and the encoded parameter. It replaces data
field, but 'data` field is still supported for backward compatibility.
value
QUANTITY
(optional) The integer of values sent with this transaction.
nonce
QUANTITY
(optional) The integer of a nonce.
Return Value
32-byte DATA
The transaction hash or the zero hash if the transaction is not yet available.
If you deployed a contract, use eth_getTransactionReceipt to get the contract address.
Example
eth_signTransaction
Signs a transaction that can be submitted to the network at a later time using with eth_sendRawTransaction.
NOTE: The address to sign with must be unlocked.
Parameters:
transactionArgs
Object
An object of transaction arguments. See the table below for the object's properties.
transactionArgs
has the following properties:
from
20-byte DATA
The address from which the transaction is sent.
to
20-byte DATA
(not required when creating a new contract) The address to which the transaction is directed.
gas
QUANTITY
The integer of the gas provided for the transaction's execution. It will return unused gas.
maxFeePerGas
QUANTITY
The maximum amount to pay for the transaction's execution.
maxPriorityFeePerGas
QUANTITY
Gas tip cap for dynamic fee transaction in peb.
input
DATA
(optional) The hash of the method signature and the encoded parameter. It replaces data
field, but 'data` field is still supported for backward compatibility.
value
QUANTITY
(optional) The integer of values sent with this transaction.
nonce
QUANTITY
The integer of a nonce.
Return Value
Object
- The signed transaction object.
raw
DATA
A rawTransaction
string (a RLP-encoded transaction string).
tx
Object
The transaction object. See the next table for the object's properties.
tx
has the following properties:
type
QUANTITY
An integer representing the type of the transaction.
nonce
QUANTITY
The block number where this transaction was in.
gasPrice
QUANTITY
Gas price provided by the sender in peb. null
when it is not a legacy transaction.
maxFeePerGas
QUANTITY
A maximum amount to pay for the transaction to execute. null
when it is a legacy transaction.
maxPriorityFeePerGas
QUANTITY
Gas tip cap for dynamic fee transaction in peb. null
when it is a legacy transaction.
gas
QUANTITY
Gas provided by the sender.
value
QUANTITY
Integer of values sent with this transaction.
v
QUANTITY
ECDSA recovery id.
r
32-byte DATA
ECDSA signature r.
s
32-byte DATA
ECDSA signature s.
chainId
QUANTITY
Chain id set on the requested node.
accessList
Array
hash
32-byte DATA
Hash of the transaction.
Example
eth_fillTransaction
Fills the defaults (nonce, gas, gasPrice or 1559 fields) on a given unsigned transaction, and returns it to the caller for further processing (signing + broadcast).
Parameters:
Parameters are same with eth_sendTransaction. See eth_sendtransaction.
Return value
See eth_signTransaction.
Example
eth_pendingTransactions
Returns the transactions that are in the transaction pool and have a from address that is one of the accounts this node manages.
Parameters:
None
Return value
pendingTransactions
Array
Example
eth_resend
Resends a transaction.
It will remove the given transaction from the pool and reinsert it with the new gas price and limit.
NOTE: The address to sign with must be unlocked.
Parameters:
transactionArgs
Object
An object of transaction arguments. See the table below for the object's properties.
gas price
QUANTITY
Integer of the gasPrice to change
gas
QUANTITY
(optional) Integer of the gas to change
transactionArgs
has the following properties:
from
20-byte DATA
The address from which the transaction is sent.
to
20-byte DATA
The address to which the transaction is directed.
gas
QUANTITY
(optional) The integer of the gas provided for the transaction's execution. It will return unused gas.
maxFeePerGas
QUANTITY
(optional) The maximum amount to pay for the transaction's execution.
maxPriorityFeePerGas
QUANTITY
(optional) Gas tip cap for dynamic fee transaction in peb.
input
DATA
(optional) The hash of the method signature and the encoded parameter. It replaces data
field, but 'data` field is still supported for backward compatibility.
value
QUANTITY
(optional) The integer of values sent with this transaction.
nonce
QUANTITY
(optional) The integer of a nonce.
Return Value
32-byte DATA
The transaction hash
Example
Last updated