3

I am new with Solana development I have deployed a program to localnet. Now I want to interact with it (call functions) My question is, is it possible to call a function on a program from the Solana CLI? https://docs.solana.com/cli/install-solana-cli-tools

Thanks

3 Answers 3

2

The cli does not offer a way to interact with a custom Solana program, there is too much information to pass to the Solana program and sending it via cli is unpractical.

Most common way to interact with Solana programs is by using JS/TS client. But you can also use other languages, like rust, python.

1

As Serban's answer mentions, the Solana CLI does not let you interact with any arbitrary program, only the builtin / native ones, like the system program, stake program, vote program, and address-lookup-table program.

To interact with your program, you will need some other tool. I highly recommend starting with a template like https://github.com/mvines/solana-cli-template if you want to build your own CLI.

It takes care of things like setting up RPC and getting the default signer, so you simply need to provide your parameters to create and send a transaction. And if you're feeling lazy, you can always hardcode things when you run the CLI :-)

0

also, you can use anchor to create & deploy your program, and it will be way easier to call it with anchor.

1
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review Commented Dec 28, 2023 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.