Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Mirror Node Contract Queries #1188

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

0xivanov
Copy link
Contributor

Description:

A new MirrorNodeContractQuery class has been introduced to support EVM gas estimation and simulation. This query class provides two distinct types of queries:

  1. MirrorNodeContractCallQuery – Executes a contract call and returns the result, simulating the execution of the contract.
  2. MirrorNodeContractEstimateGasQuery – Estimates the gas usage for a contract call, allowing developers to understand the cost of executing a transaction.

The inputs for these queries match those of ContractExecuteTransaction, making it easy for developers to calculate the cost of a follow-up transaction.

The MirrorNodeContractQuery issues an HTTP request to the api/v1/contracts/call endpoint of the Mirror Node Web3 module, which supports both gas estimation and transient simulation of state-changing transactions. This enables accurate cost predictions and helps developers optimize their contract interactions before executing them on the network.

Related issue(s):

Fixes #1167

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

Signed-off-by: Ivan Ivanov <[email protected]>
Signed-off-by: Ivan Ivanov <[email protected]>
@0xivanov 0xivanov added the enhancement New feature or request label Dec 13, 2024
@0xivanov 0xivanov self-assigned this Dec 13, 2024
Copy link

codecov bot commented Dec 13, 2024

Codecov Report

Attention: Patch coverage is 10.06494% with 277 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
mirror_node_contract_query.go 0.00% 196 Missing ⚠️
mirror_node_contract_call_query.go 0.00% 32 Missing ⚠️
mirror_node_contract_estimate_gas_query.go 0.00% 29 Missing ⚠️
contract_id.go 59.18% 17 Missing and 3 partials ⚠️
Files with missing lines Coverage Δ
account_id.go 65.83% <100.00%> (ø)
contract_id.go 65.72% <59.18%> (-4.44%) ⬇️
mirror_node_contract_estimate_gas_query.go 0.00% <0.00%> (ø)
mirror_node_contract_call_query.go 0.00% <0.00%> (ø)
mirror_node_contract_query.go 0.00% <0.00%> (ø)

... and 1 file with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a query to estimate the gas of a contract call
1 participant