useSignTransaction
Sign a Solana transaction with your customers' Comet wallet.
Last updated
Sign a Solana transaction with your customers' Comet wallet.
Last updated
Since Comet accounts come with a built-in cloud wallet, you can use this wallet to provide a signature for any Solana transaction using the useSignTransaction
hook. The user will be prompted to log in if necessary, and will be asked to confirm the transaction to be signed (similar to the flow for Metamask or Phantom wallets).
In the example above, TRANSACTION
is a Transaction
object generated by the Solana Web3 library (see @solana/web3.js
).
signTransaction
is a function that can be called later on, which brings up a confirmation dialog. When the user clicks "Sign", the transaction is partially signed by the private key in the user's Comet wallet. Keep in mind that if the transaction requires additional signatures, those will need to be provided separately.
signTransaction
returns a successful Promise
containing the Transaction
object with the added signature, or a failed Promise
if the user clicks "Cancel".