Skip to content
This repository has been archived by the owner on May 4, 2023. It is now read-only.

How could I get a function iterator of a contract which can be put in as a parameter in eve.call() #41

Open
fCorleone opened this issue Oct 15, 2018 · 4 comments

Comments

@fCorleone
Copy link

I found that if I want to call a function of a contract , this line will be used:

eve.call(contract.functions().NAME_OF_YOUR_FUNCTIONS());

How could I get all of the functions' iterator of function list of a contract.
Thanks a lot if you could do me a favor.

@tomusdrw
Copy link
Collaborator

@fCorleone we don't expose anything like that currently. Could you elaborate why it would be useful? IT's also more ethabi issue than sol-rs.

@fCorleone
Copy link
Author

Yes, for the reason that I want to write a program that could parse a contract and get the function name of the contract, and automatically call the functions. But I just don't know how to write evm.call() line. Because the parameter put into the call function should be like contract.function.name(), but I can just get a string to represent the name of the function. So I wonder if I could change the string to the correct type so that I can put it into the eve.call function

@tomusdrw
Copy link
Collaborator

The whole point of ethabi-derive is to provide type-safe wrapper for contracts, so you cannot dynamically call a function given it's function name as a string, cause you wouldn't know what types of parameters it's expecting or returns.

What you can do is use ethabi directly, like here: https://docs.rs/ethabi/6.0.1/ethabi/struct.Contract.html#method.function
This is untyped API that gives you a builder that will produce data field of a transaction that you should send to interact with the contract.
You will most likely need to contstruct ActionParams on your own (https://github.com/paritytech/sol-rs/blob/master/solaris/src/evm.rs#L260), and maybe even expose more "raw" function to perform a call than current EVM exposes.

@fCorleone
Copy link
Author

Thank you a lot about this, it's very useful to me.

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

No branches or pull requests

3 participants
@tomusdrw @fCorleone and others