Sending Transactions
Overview
This guide covers the fundamentals of signing and sending transactions on Solana using the CDP v2 Wallet API. You will learn how to construct transactions, sign them with CDP-managed keys, and submit them to the Solana network.
With CDP, signing keys are securely managed in the platform’s infrastructure. While EVM transactions benefit from a single API that supports signing and broadcasting, Solana requires explicit handling of the transaction lifecycle:
- Create transaction: Build a transaction with one or more instructions
- Set recent blockhash: Add a recent blockhash for transaction expiry
- Sign transaction: Use CDP to sign the serialized transaction
- Send transaction: Submit the signed transaction to the network
- Confirm transaction: Wait for network confirmation
How CDP handles transaction signing
How CDP handles transaction signing
When you call cdp.solana.signTransaction()
, you send an unsigned transaction to CDP’s secure infrastructure. CDP signs it using your managed private key (which never leaves the Trusted Execution Environment) and returns the signed transaction.
Prerequisites
It is assumed you have:
- Completed the Quickstart guide
- Basic understanding of Solana accounts
- Installed dependencies:
- For TypeScript:
@solana/web3.js
,@coinbase/cdp-sdk
, anddotenv
- For Python:
solana
,solders
,cdp-sdk
, andpython-dotenv
- For TypeScript:
The following steps break down the transaction flow into digestible pieces. If you prefer to see the full working code immediately, skip to the Complete example section below.
1. Create a Solana account
First, create or retrieve a Solana account using CDP. The below example uses solana-devnet
and will source SOL
from CDP faucet to transfer.
2. Build the transaction
Prepare a transaction with one or more instructions. Here is a simple SOL transfer (note that we fetch the latest blockhash from the network, which is required for transaction expiry):
3. Set blockhash and serialize
Add a recent blockhash and serialize the transaction for signing:
4. Sign the transaction
Use CDP to sign the serialized transaction:
5. Send and confirm
Submit the signed transaction to the network and wait for confirmation:
Complete example
View complete runnable examples
View complete runnable examples
Here’s the complete, runnable example for easy copy and paste:
More code samples are available in our TypeScript and Python SDK repositories.
What to read next
- Batching instructions: Learn how to batch multiple instructions efficiently
- Sponsor transactions: Implement fee sponsorship for better UX
- Solana accounts: Understand Solana account management in CDP
- API reference: Complete API documentation for all Solana operations