-
Notifications
You must be signed in to change notification settings - Fork 34
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(contract): interact using ContractInstance
#109
Conversation
let init_val = counter_instance.function("number", &[])?.call().await?; | ||
|
||
// Get the Uint value from the result | ||
let init_val = init_val.first().unwrap().as_uint().unwrap().0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly this is not a great example because we know ahead of time the functions we're going to call, and the return types of the functions, which is where sol!
should be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this example just serves an introduction ContractInstance
API interface. I can add another example where we call the function by the selector and match DynSolValue
on the return.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And anyways, we still require an abi so don't we always have some idea of which function we're trying to call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No because the ABI is supposed to be dynamic, think Foundry that executes fuzz functions with arbitrary parameters
Not entirely clear why we need this example, I think we should steer users to using the Could we instead enhance https://github.com/alloy-rs/examples/blob/main/examples/contracts/examples/interact_with_abi.rs? Or alternatively - implement it to resolve #52? |
I think we want 1 example using Dyn ABI for both normal structs and tuples, given CLIs which don't know the ABI ahead of time can't leverage the sol macro? |
Motivation
Show how to interact with an already deployed contract.
Solution
Use the
ContractInstance
interface.PR Checklist