I am trying to send a transaction using the JSON-RPC API. But it requires me to send a fully signed transaction
Currently, the Solana docs only mention how to sign a transaction with the solana-cli and not with the API. Is there any way by which it might be possible?
-
Have you considered using @solana/web3.js ?– dadeCommented Sep 29, 2022 at 22:07
-
I am using rust unfortunately. Sorry for the late reply. Had gotten busy on other projects– LionCatDev StudioCommented Oct 6, 2022 at 13:42
-
Did you ever figure this out? I am specifically building an app that doesn't use web3.js, and this is essential functionality I am trying to implement.– david lampachCommented Jan 23, 2023 at 0:23
-
Not sure if LionCatDev still needs this, but I've just added an answer for this @davidlampach– McBainCommented Jan 28, 2023 at 22:08
-
I would also like to see an answer for baremetal, no sdk available: only json and cryptographic functions. The docs only mention a "fully signed transaction, encoded as a string". I would like to know what is the transaction itself, how is it signed and how is it encoded.– CrossedCarpetCommented Feb 28, 2023 at 8:12
1 Answer
The JSON-RPC API is meant for querying and sending data, not for actively creating or mutating it. As your error message indicates, you should be signing your transaction BEFORE it interacts with the JSON-RPC API. If you check all supported functions of the JSON-RPC API, you will see there is no way to sign a transaction using it.
So what should you do instead? You should use the solana-sdk crate inside your rust project, create your transaction there and sign it using the sdk's sign method.