sendTransaction - Solana
The sendTransaction JSON-RPC method broadcasts a signed transaction to the Solana network, enabling Web3 sendTransaction operations like token transfers, smart contract interactions, and NFT minting
The sendTransaction RPC Solana method submits a fully signed transaction (encoded as a string) to the blockchain.
As a core component of Solana’s JSON-RPC framework, it allows developers to execute on-chain actions while controlling parameters like preflight checks, retries, and encoding formats.
Unlike Ethereum’s viem sendTransaction, which handles gas estimation and signing, Solana requires transactions to be pre-signed and serialized. This API method is critical for applications requiring real-time block inclusion, such as exchanges or gaming platforms.
Supported Networks
Access this method via Solana API Endpoints:
Mainnet
Devnet
Parameters
transaction (string, required):
The signed transaction, encoded as a base58 or base64 string.
config (object, optional):
Customize transaction handling with these fields:
skipPreflight (bool, optional): Bypass preflight checks (default: false). Use cautiously to speed up requests.
preflightCommitment (string, optional): Commitment level for preflight verification (default: finalized).
encoding (string, optional): Transaction encoding: base58 (deprecated) or base64 (recommended).
maxRetries (usize, optional): Maximum retry attempts by the RPC node before abandoning the transaction.
Request
API Endpoints:
sendTransaction example (cURL)
Response
A successful response returns the transaction signature. If the blockhash is expired or the node is out of sync, a sendTransaction error occurs.
Example Success Response:
Example Error Response (sendTransaction error):
Error Handling
Common sendTransaction error scenarios include:
Expired blockhash (transaction too old).
Insufficient balance for fees.
Invalid transaction encoding or signature.
RPC node synchronization issues.
Retry with maxRetries or a fresh blockhash to resolve transient errors.
Use Cases
The sendTransaction RPC Solana method is ideal for:
Wallets executing user-initiated transfers or swaps.
dApps submitting on-chain votes or NFT actions.
DeFi protocols processing liquidations or staking.
Games minting in-game assets.
By configuring skipPreflight, developers reduce latency for time-sensitive transactions while accepting higher failure risks.
Code Example (JavaScript) – Web3 sendTransaction Integration
Integration with Web3
Integrate the sendTransaction RPC Solana method into Web3 applications to enable seamless on-chain interactions. By leveraging Core API parameters like preflightCommitment and maxRetries, developers balance speed and reliability for transactions, ensuring optimal user experiences in wallets, dApps, and trading platforms.
Last updated