Sign and send on Solana
Once you’ve created a smart wallet on Solana, send transactions and sign messages using the useSolanaTransaction
and useSolanaSignMessage
hooks. You can also add mutliplie signers to your Solana wallet.
Sending Solana transactions
To send a transaction from an embedded Solana wallet, use the sendTransaction
method from the useSolanaTransaction
hook.
- This method supports signing both single and batched transactions and integrates seamlessly with popular web3 libraries like
@solana/web3js
. - You’ll need to use a web3 library to construct and submit transactions.
Want to sponsor gas for Solana transactions? Skip to this guide for sending sponsored transactions.
Send a single transaction
Send a batched transaction
Batch multiple Solana instructions into a single transaction.
How does sendTransaction
work?
The sendTransaction
method will construct and send a Solana transaction using the connection you provide. You can either construct a transaction using simple parameters or instructions for finer grained control.
Using simple transfer parameters:
Using instructions:
If you want finer grained control like transfer and nonceAdvance
you can pass instructions by using the exposed web3 SystemProgram.
Sign messages
Sign messages (either a string or a byte array) with your Solana wallet by using the useSolanaSignMessage
hook.
Multi-signature support using custom signers
You can implement multi-signature behavior using the preSign
feature to authorize multiple signers on a transaction before execution.
Example use case: adding additional signers
A common pattern involves supporting multiple signers for a single transaction. For example, in our demo environment, we generate a temporary (or “throwaway”) account that can hold various tokens. However, this account alone isn’t sufficient for transaction security or coordination.
To enable multi-signature functionality, we attach additional signers to the transaction using preSign
. This allows the transaction to be authorized by multiple parties before being broadcast, ensuring that:
- Multiple stakeholders can approve a transaction.
- Tokens can exist at a shared account address with controlled access.
- Coordination between signers happens off-chain via pre-signed approvals.
Example flow:
- Create a transaction from a temporary account.
- Add one or more
preSign
signatures from required co-signers. - Submit the fully signed transaction.
Learn more about Solana multisig.