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

Ability to call non-constant function #16

Open
1 of 2 tasks
hayesgm opened this issue Mar 30, 2018 · 5 comments
Open
1 of 2 tasks

Ability to call non-constant function #16

hayesgm opened this issue Mar 30, 2018 · 5 comments

Comments

@hayesgm
Copy link

hayesgm commented Mar 30, 2018

ethjs-contract

Issue Type

Description

The current implementation decides whether to make a gas-free call or execute a transaction based on the whether the ABI specifies the function is constant or not. Here is the relevant code line. While this decision makes sense in the general case, it doesn't allow us to use this library to make a call to a non-constant function (e.g. to check to see if it's likely to succeed), or to execute a transaction to a constant function (well, less of a use-case for that one). In either case, it would be nice to allow the caller of this library to specify call versus sendTransaction from either a flag to the current functions or by defining a separate set of functions.

A current work-around is to redefine the ABI to mark a non-constant function constant and pass that ABI to this library.

This is a feature request to allow a caller of this library to make a gas-free call to a non-constant function without redefining the ABI. Any proper implementation will suffice, and I am happy to help define what this might look like if there's interest in this request.

@SilentCicero
Copy link
Member

SilentCicero commented Mar 31, 2018 via email

@hayesgm
Copy link
Author

hayesgm commented Apr 2, 2018

Nick,

Sure thing. This will take me a few days since I'm traveling, but I'll follow-up with a suggestion and then an implementation shortly. I am currently working around the feature by marking the ABI (incorrectly) as constant, which solves the proximate issue for my project.

Thanks, -Geoff

@SilentCicero
Copy link
Member

SilentCicero commented Apr 3, 2018 via email

@hayesgm
Copy link
Author

hayesgm commented Apr 9, 2018

Nick, my first thought (that would be the easiest) would be to add a simple field to the "transaction object" called execute. execute would take one of three states:

  • {execute: true} implies that we should always execute this call as a transaction
  • {execute: false} implies that we should never execute this call as a transaction (instead, querying)
  • {execute: undefined} queries when the ABI specifies a constant function, and executes when non-constant (current behavior)

This change would be very easy to implement and be fully backwards compatible.

@SilentCicero
Copy link
Member

SilentCicero commented Apr 9, 2018 via email

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

No branches or pull requests

2 participants