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

forc call help for callable functions #6950

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Dhanraj30
Copy link

Description

This PR enhances the forc call --help command to print out all callable functions of the contract from the provided ABI and provide examples of how to call each function. This makes it easier for users to know what functions are available on the callable contract. This update includes:

  • Parsing the ABI to retrieve callable functions.
  • Printing the list of functions available in the ABI.
  • Providing examples of how to call each function, including the required parameters.
  • Fixes issue Forc call help for callable functions #6935.

@Dhanraj30 Dhanraj30 marked this pull request as ready for review February 22, 2025 18:43
@Dhanraj30 Dhanraj30 requested a review from a team as a code owner February 22, 2025 18:43
@zees-dev
Copy link
Contributor

Thanks for this; however I was envisioning a different approach here.
For example; running forc call --help should print out the current help.
Running forc call --abi <..> <CONTRACT-ID> --help should parse the ABI; read the functions, and give examples on how to call them; below the current help output.
These should be something which can simply be copy-pasted by the user themselves for execution.
E.g.

> forc call --abi ./out/debug/counter-contract-abi.json 0xe18de7c7c8c61a1c706dccb3533caa00ba5c11b5230da4428582abf1b6831b4d --help
# current help output omitted..

Contract Functions:

add(u32,u32)
> forc call --abi ./out/debug/counter-contract-abi.json 0xe18de7c7c8c61a1c706dccb3533caa00ba5c11b5230da4428582abf1b6831b4d add 1 2

sub(u32,u32)
> forc call --abi ./out/debug/counter-contract-abi.json 0xe18de7c7c8c61a1c706dccb3533caa00ba5c11b5230da4428582abf1b6831b4d sub 1 2

Doesn't have to be perfect; i can imagine some complexity with complex structs/enums/generics - but something along these lines is what's expected.

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

Successfully merging this pull request may close these issues.

2 participants