Smart Contracts
Overview
The Smart Contracts endpoints in the Hedera Mirror Node REST API allows developers to query smart contract metadata, execution results, state changes, and logs. These endpoints are essential for tracking contract interactions, retrieving transaction results, and debugging contract executions on the Hedera network.
Endpoints
The following endpoints are available for the Smart Contracts object:
Endpoint
Description
GET /api/v1/contracts
Retrieves a list of smart contract entities on the network.
GET /api/v1/contracts/{id}
Fetches details of a specific contract by ID.
GET /api/v1/contracts/{id}/results
Retrieves execution results for a specific contract.
GET /api/v1/contracts/{id}/state
Fetches the latest state of a contract.
GET /api/v1/contracts/results
Lists execution results for all contracts.
GET /api/v1/contracts/results/{timestamp}
Retrieves execution results for a contract at a given timestamp.
GET /api/v1/contracts/logs
Lists logs emitted from contracts.
GET /api/v1/contracts/logs/{id}
Fetches logs for a specific contract.
POST /api/v1/contracts/call
Invokes a smart contract method.
Smart Contracts
List contract entities on network
Returns a list of all contract entity items on the network.
/api/v1/contracts
The ID of the smart contract
^((gte?|lte?|eq|ne)\:)?(\d{1,10}\.\d{1,10}\.)?\d{1,10}|(\d{1,10}\.){0,2}[A-Fa-f0-9]{40}$
The maximum number of items to return
2
The order in which items are listed
asc
asc
, desc
admin_key
The admin key of the contract, if specified
auto_renew_account
The account paying the auto renew fees, if set
auto_renew_period
The period at which the contract auto renews
bytecode
The bytecode of the contract
contract_id
The contract ID
created_timestamp
The timestamp the contract was created at
deleted
Whether or not the contract is deleted
evm_address
The EVM address of the contract
expiration_timestamp
The timestamp of when the contract is set to expire
file_id
The ID of the file that stored the contract bytecode
max_automatic_token_associations
The number of automatic token association slots
memo
The memo of the contract, if specified
obtainer_id
The ID of the account or contract that will receive any remaining balance when the contract is deleted
permanent_removal
Set to true
when the system expires a contract
proxy_account_id
The proxy account ID (disabled)
solidity_address
The solidity address
timestamp
The period for which the attributes are valid for
Get contract by id
Return the contract information given an id
/api/v1/contracts/{contractIdOrAddress}
The ID or hex encoded EVM address (with or without 0x prefix) associated with this contract.
^(\d{1,10}\.){0,2}(\d{1,10}|(0x)?[A-Fa-f0-9]{40})$
The consensus timestamp as a Unix timestamp in seconds.nanoseconds format with an optional comparison operator. See unixtimestamp.com for a simple way to convert a date to the 'seconds' part of the Unix time.
List contract results from a contract on the network
Returns a list of all ContractResults for a contract's function executions.
/api/v1/contracts/{contractIdOrAddress}/results
The ID or hex encoded EVM address (with or without 0x prefix) associated with this contract.
^(\d{1,10}\.){0,2}(\d{1,10}|(0x)?[A-Fa-f0-9]{40})$
The block's hash. If multiple values are provided the last value will be the only value used.
^(eq:)?(0x)?([0-9A-Fa-f]{64}|[0-9A-Fa-f]{96})$
The block's number
^(eq:)?(\d{1,19}|0x[a-fA-f0-9]+)$
Account ID or EVM address executing the contract
^\d{1,10}\.\d{1,10}\.\d{1,10}|(0x)?[A-Fa-f0-9]{40}$
Whether to include child transactions or not
true
The maximum number of items to return
2
The order in which items are listed
asc
asc
, desc
The consensus timestamp as a Unix timestamp in seconds.nanoseconds format with an optional comparison operator. See unixtimestamp.com for a simple way to convert a date to the 'seconds' part of the Unix time.
The transaction index in the block
1
The contract state from a contract on the network
Returns a list of all contract's slots. If no timestamp is provided, returns the current state.
/api/v1/contracts/{contractIdOrAddress}/state
The ID or hex encoded EVM address (with or without 0x prefix) associated with this contract.
^(\d{1,10}\.){0,2}(\d{1,10}|(0x)?[A-Fa-f0-9]{40})$
The maximum number of items to return
2
The order in which items are listed
desc
asc
, desc
The slot's number
^((eq|gte?|lte?)\:)?(0x)?[0-9A-Fa-f]{1,64}$
The consensus timestamp of the contract state as a Unix timestamp in seconds.nanoseconds format with an optional comparison operator. See unixtimestamp.com for a simple way to convert a date to the 'seconds' part of the Unix time.
Get the contract result from a contract on the network executed at a given timestamp
Returns a single ContractResult for a contract's function executions at a specific timestamp.
/api/v1/contracts/{contractIdOrAddress}/results/{timestamp}
The ID or hex encoded EVM address (with or without 0x prefix) associated with this contract.
^(\d{1,10}\.){0,2}(\d{1,10}|(0x)?[A-Fa-f0-9]{40})$
The Unix timestamp in seconds.nanoseconds format, the timestamp at which the associated transaction reached consensus. See unixtimestamp.com for a simple way to convert a date to the 'seconds' part of the Unix time.
1234567890.0000007
^\d{1,10}(.\d{1,9})?$
List contract results from all contracts on the network
Returns a list of all ContractResults for all contract's function executions.
/api/v1/contracts/results
Account ID or EVM address executing the contract
^\d{1,10}\.\d{1,10}\.\d{1,10}|(0x)?[A-Fa-f0-9]{40}$
The block's hash. If multiple values are provided the last value will be the only value used.
^(eq:)?(0x)?([0-9A-Fa-f]{64}|[0-9A-Fa-f]{96})$
The block's number
^(eq:)?(\d{1,19}|0x[a-fA-f0-9]+)$
Whether to include child transactions or not
true
The maximum number of items to return
2
The order in which items are listed
asc
asc
, desc
The consensus timestamp as a Unix timestamp in seconds.nanoseconds format with an optional comparison operator. See unixtimestamp.com for a simple way to convert a date to the 'seconds' part of the Unix time.
The transaction index in the block
1
Get the contract result from a contract on the network for a given transactionId or ethereum transaction hash
Returns a single ContractResult for a contract's function executions for a given transactionId or ethereum transaction hash.
/api/v1/contracts/results/{transactionIdOrHash}
Transaction Id or a 32 byte hash with optional 0x prefix
^(0x)?[A-Fa-f0-9]{64}|(\d{1,10})\.(\d{1,10})\.(\d{1,10})-(\d{1,19})-(\d{1,9})$
Filter the query result by the nonce of the transaction. A zero nonce represents user submitted transactions while a non-zero nonce is generated by main nodes. The filter honors the last value. Default is 0 when not specified.
1
Get the contract actions from a contract on the network for a given transactionId or ethereum transaction hash
Returns a list of ContractActions for a contract's function executions for a given transactionId or ethereum transaction hash.
/api/v1/contracts/results/{transactionIdOrHash}/actions
Transaction Id or a 32 byte hash with optional 0x prefix
^(0x)?[A-Fa-f0-9]{64}|(\d{1,10})\.(\d{1,10})\.(\d{1,10})-(\d{1,19})-(\d{1,9})$
The index of a contract action
^((gte?|lte?|eq|ne)\:)?\d{1,10}$
The maximum number of items to return
2
The order in which items are listed
desc
asc
, desc
Get the opcode traces for a historical transaction on the network with the given transaction ID or hash
Re-executes a transaction and returns a result containing detailed information for the execution, including all values from the {@code stack}, {@code memory} and {@code storage} and the entire trace of opcodes that were executed during the replay.
Note that to provide the output, the transaction needs to be re-executed on the EVM, which may take a significant amount of time to complete if stack and memory information is requested.
/api/v1/contracts/results/{transactionIdOrHash}/opcodes
Transaction Id or a 32 byte hash with optional 0x prefix
^(0x)?[A-Fa-f0-9]{64}|(\d{1,10})\.(\d{1,10})\.(\d{1,10})-(\d{1,19})-(\d{1,9})$
If provided and set to false, stack information will not be included in the response
true
If provided and set to true, memory information will be included in the response
false
If provided and set to true, storage information will be included in the response
false
List contract logs from a contract on the network
Search the logs of a specific contract across multiple contract calls. Chained logs are not
included but can be found by calling /api/v1/contracts/{contractId}/results/{timestamp}
or /api/v1/contracts/results/{transactionId}
. When searching by topic a timestamp parameter must be supplied
and span a time range of at most seven days.
Ordering
The order is governed by the combination of timestamp and index values. If the index param is omitted, the order is determined by the timestamp only.
Note: The default order for this API is currently DESC
Filtering
When filtering there are some restrictions enforced to ensure correctness and scalability.
The table below defines the restrictions and support for the endpoint
Query Param | Comparison Operator | Support | Description | Example |
---|---|---|---|---|
index | eq | Y | Single occurrence only. Requires the presence of timestamp | ?index=X |
ne | N | |||
lt(e) | Y | Single occurrence only. Requires the presence of timestamp | ?index=lte:X | |
gt(e) | Y | Single occurrence only. Requires the presence of timestamp | ?index=gte:X | |
timestamp | eq | Y | Single occurrence only. | ?timestamp=Y |
ne | N | |||
lt(e) | Y | Single occurrence only. Optional second timestamp gt(e) | ?timestamp=lte:Y | |
gt(e) | Y | Single occurrence only. Optional second timestamp lt(e) | ?timestamp=gte:Y |
Both filters must be a single occurrence of gt(e) or lt(e) which provide a lower and or upper boundary for search.
/api/v1/contracts/{contractIdOrAddress}/results/logs
The ID or hex encoded EVM address (with or without 0x prefix) associated with this contract.
^(\d{1,10}\.){0,2}(\d{1,10}|(0x)?[A-Fa-f0-9]{40})$
Contract log index
^((eq|gt|gte|lt|lte):)?\d{1,10}$
The maximum number of items to return
2
The order in which items are listed
asc
asc
, desc
The consensus timestamp as a Unix timestamp in seconds.nanoseconds format with an optional comparison operator. See unixtimestamp.com for a simple way to convert a date to the 'seconds' part of the Unix time.
The first topic associated with a contract log. Requires a timestamp range also be populated.
The second topic associated with a contract log. Requires a timestamp range also be populated.
The third topic associated with a contract log. Requires a timestamp range also be populated.
The fourth topic associated with a contract log. Requires a timestamp range also be populated.
List contracts logs across many contracts on the network
Search the logs across many contracts with multiple contract calls. Chained logs are not
included but can be found by calling /api/v1/contracts/{contractId}/results/{timestamp}
or /api/v1/contracts/results/{transactionId}
. When searching by topic a timestamp parameter must be supplied
and span a time range of at most seven days.
Ordering
The order is governed by the combination of timestamp and index values. If the index param is omitted, the order is determined by the timestamp only.
Note: The default order for this API is currently DESC
Filtering
When filtering there are some restrictions enforced to ensure correctness and scalability.
The table below defines the restrictions and support for the endpoint
Query Param | Comparison Operator | Support | Description | Example |
---|---|---|---|---|
index | eq | Y | Single occurrence only. Requires the presence of timestamp | ?index=X |
ne | N | |||
lt(e) | Y | Single occurrence only. Requires the presence of timestamp | ?index=lte:X | |
gt(e) | Y | Single occurrence only. Requires the presence of timestamp | ?index=gte:X | |
timestamp | eq | Y | Single occurrence only. | ?timestamp=Y |
ne | N | |||
lt(e) | Y | Single occurrence only. Optional second timestamp gt(e) | ?timestamp=lte:Y | |
gt(e) | Y | Single occurrence only. Optional second timestamp lt(e) | ?timestamp=gte:Y |
Both filters must be a single occurrence of gt(e) or lt(e) which provide a lower and or upper boundary for search.
/api/v1/contracts/results/logs
Contract log index
^((eq|gt|gte|lt|lte):)?\d{1,10}$
The maximum number of items to return
2
The order in which items are listed
asc
asc
, desc
The consensus timestamp as a Unix timestamp in seconds.nanoseconds format with an optional comparison operator. See unixtimestamp.com for a simple way to convert a date to the 'seconds' part of the Unix time.
The first topic associated with a contract log. Requires a timestamp range also be populated.
The second topic associated with a contract log. Requires a timestamp range also be populated.
The third topic associated with a contract log. Requires a timestamp range also be populated.
The fourth topic associated with a contract log. Requires a timestamp range also be populated.
A hex encoded 32-byte ethereum transaction hash or 48-byte hedera transaction hash.
^(eq:)?(0x)?([0-9A-Fa-f]{64}|[0-9A-Fa-f]{96})$
Invoke a smart contract
Returns a result from EVM execution such as cost-free execution of read-only smart contract queries, gas estimation, and transient simulation of read-write operations. If the estimate
field is set to true gas estimation is executed. However, gas estimation only supports the latest
block. When estimate
is false, it can process calls against the earliest
block and specific historical blocks when a hexadecimal or decimal block number is provided in the block
field for eth_call
operations. Link to Supported/Unsupported Operations Table
The operations types which are not currently supported should return 501 error status.
/api/v1/contracts/call
Hexadecimal block number or the string "latest", "pending", "earliest". Defaults to "latest".
latest
^((0x)?[0-9a-fA-F]+|(earliest|pending|latest))$
Hexadecimal method signature and encoded parameters. Up to 24656 bytes as at most 49152 hexidecimal digits plus optional leading 0x.
0x47f1aae7
^(0x)?[0-9a-fA-F]+$
Whether gas estimation is called. Defaults to false.
true
The 20-byte hexadecimal EVM address the transaction is sent from.
00000000000000000000000000000000000004e2
^(0x)?[A-Fa-f0-9]{40}$
Gas provided for the transaction execution. Defaults to 15000000.
15000000
Gas price used for each paid gas.
100000000
The 20-byte hexadecimal EVM address the transaction is directed to.
0xd9d0c5c0ff85758bdf05a7636f8036d4d065f5b6
^(0x)?[A-Fa-f0-9]{40}$
Value sent with this transaction. Defaults to 0.
0
Last updated
Was this helpful?