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

Create a generic estimateGas() function #1391

Closed
miquelcabot opened this issue Apr 4, 2022 · 5 comments · Fixed by #1394
Closed

Create a generic estimateGas() function #1391

miquelcabot opened this issue Apr 4, 2022 · 5 comments · Fixed by #1394
Assignees
Labels
Type: Enhancement New feature or request

Comments

@miquelcabot
Copy link
Contributor

Create a generic estimateGas() function that can be used whenever we want to estimate gas in a function.

@miquelcabot miquelcabot added the Type: Enhancement New feature or request label Apr 4, 2022
@miquelcabot miquelcabot self-assigned this Apr 4, 2022
@alexcos20
Copy link
Member

Not sure if it's doable.
We have multiple contracts, with multiple ABIs, with multiple functions with variable number of arguments :)

also, frontend needs to estimate some transactions before hand, so it needs to be able to access that estimateGasXXX functions.

@miquelcabot
Copy link
Contributor Author

@alexcos20 I think that it's possible. I have created an example of how to do it in another PR:

export async function estimateGas(

@alexcos20
Copy link
Member

and how market will call that?

export async function estimateGas(
  tokenContract: Contract,
  from: string,
  functionSignature: string,

so market needs to know the contract, which is kind of ocean.js internal so far.

@miquelcabot
Copy link
Contributor Author

@alexcos20 Ok, you're right. I thought that these "estimate gas" functions must be called only from inside the ocean.js functions. In that case, I can do some research about if there exists a simple solution to achieve it. Perhaps, using constants that stores the interface of the functions or simpler solutions, taking advantage of the exported ABIs from @oceanprotocols/contracts

@miquelcabot
Copy link
Contributor Author

@alexcos20 I think that I have found a very simple solution to having a generic estimateGas() function without the need of the interface of the functions. You can review it here:

export async function estimateGas(

With this, we only need three parameters:

  • The function of the smart contract that we need to estimate the gas
  • The caller of the function
  • The parameters of the funcion

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

Successfully merging a pull request may close this issue.

2 participants