ConnectionBasedForwarder
Umbra SDK reference for Connection Based Forwarder.
Defined in: src/client/implementation/connection-based-forwarder.ts:137
Transaction forwarder implementation that uses a Solana Connection to forward transactions.
Remarks
This forwarder directly submits transactions to the Solana network using the provided
Connection instance. It supports forwarding single transactions and batches of transactions,
with optional delays between transactions to prevent rate limiting.
Features:
- Direct RPC submission via Solana Connection
- Sequential transaction forwarding with confirmation
- Fixed and variable delay support between transactions (after confirmation)
- Comprehensive error handling with specific error types
Example
// Create from existing connection
const connection = new Connection('https://api.mainnet-beta.solana.com');
const forwarder = ConnectionBasedForwarder.fromConnection(connection);
// Or create from RPC URL
const forwarder = ConnectionBasedForwarder.fromRpcUrl('https://api.mainnet-beta.solana.com');
// Forward a single transaction
const signature = await forwarder.forwardTransaction(signedTx);
// Forward multiple transactions sequentially (each confirmed before next)
const signatures = await forwarder.forwardTransactions([tx1, tx2, tx3]);
// Forward with fixed delay
const signatures = await forwarder.forwardTransactions([tx1, tx2, tx3], 500);
// Forward with variable delays
const delays = [200, 500, 300];
const signatures = await forwarder.forwardTransactions([tx1, tx2, tx3, tx4], delays);
// Resume from offset with fixed delay
const signatures = await forwarder.forwardTransactions([tx1, tx2, tx3], 1, 500);
// Resume from offset with variable delays
const delays = [200, 500];
const signatures = await forwarder.forwardTransactions([tx1, tx2, tx3, tx4], 1, delays);Extends
Properties
connection
readonlyconnection:Connection
Defined in: src/client/implementation/connection-based-forwarder.ts:141
The Solana Connection instance used for forwarding transactions.
Methods
forwardTransaction()
forwardTransaction(
transaction):Promise<string>
Defined in: src/client/implementation/connection-based-forwarder.ts:213
Forwards a single signed transaction to the network and waits for confirmation.
Parameters
transaction
VersionedTransaction
The signed VersionedTransaction to forward
Returns
Promise<string>
A promise resolving to the transaction signature
Throws
TransactionForwardingError When forwarding fails due to network errors, invalid transaction, insufficient fees, or connection issues
Remarks
This method submits a single signed transaction to the Solana network using the
underlying Connection's sendTransaction method and waits for confirmation before
returning. The transaction must be fully signed before calling this method.
Example
const signedTx = await signer.signTransaction(transaction);
const signature = await forwarder.forwardTransaction(signedTx);
console.log(`Transaction forwarded and confirmed: ${signature}`);Overrides
ITransactionForwarder.forwardTransaction
forwardTransactions()
Internal
Implementation of forwardTransactions that handles all overloads.
Call Signature
forwardTransactions(
transactions):Promise<string[]>
Defined in: src/client/implementation/connection-based-forwarder.ts:253
Forwards multiple signed transactions to the network in a batch operation.
Parameters
transactions
VersionedTransaction[]
Array of signed VersionedTransaction objects to forward
Returns
Promise<string[]>
A promise resolving to an array of transaction signatures in the same order as input
Throws
BatchTransactionForwardingError When forwarding fails for any transaction in the batch
Remarks
This method submits multiple signed transactions to the Solana network sequentially. Each transaction is sent and confirmed before the next one is sent. All transactions must be fully signed before calling this method.
Execution Flow:
- Send and confirm
transactions[0] - Send and confirm
transactions[1] - Continue for all transactions
Example
const signedTxs = await signer.signTransactions(transactions);
const signatures = await forwarder.forwardTransactions(signedTxs);
// signatures[0] corresponds to transactions[0], signatures[1] to transactions[1], etc.Overrides
ITransactionForwarder.forwardTransactions
Call Signature
forwardTransactions(
transactions,delayMs):Promise<string[]>
Defined in: src/client/implementation/connection-based-forwarder.ts:287
Forwards multiple signed transactions to the network with a fixed delay between each transaction.
Parameters
transactions
VersionedTransaction[]
Array of signed VersionedTransaction objects to forward
delayMs
number
Fixed delay in milliseconds to wait between forwarding each transaction
Returns
Promise<string[]>
A promise resolving to an array of transaction signatures in the same order as input
Throws
BatchTransactionForwardingError When forwarding fails for any transaction in the batch
Remarks
This overload submits transactions sequentially with a fixed delay between each submission. The delay helps prevent rate limiting and allows for better transaction ordering control.
Execution Flow:
- Send and confirm
transactions[0] - Wait
delayMsmilliseconds - Send and confirm
transactions[1] - Wait
delayMsmilliseconds - Continue for all transactions
This is useful when you need to space out transactions to avoid network congestion or rate limiting issues.
Example
const signedTxs = await signer.signTransactions(transactions);
// Forward with 500ms delay between each transaction
const signatures = await forwarder.forwardTransactions(signedTxs, 500);Overrides
ITransactionForwarder.forwardTransactions
Call Signature
forwardTransactions(
transactions,delaysMs):Promise<string[]>
Defined in: src/client/implementation/connection-based-forwarder.ts:328
Forwards multiple signed transactions to the network with variable delays between transactions.
Parameters
transactions
VersionedTransaction[]
Array of signed VersionedTransaction objects to forward
delaysMs
number[]
Array of delays in milliseconds between each transaction (must have length transactions.length - 1)
Returns
Promise<string[]>
A promise resolving to an array of transaction signatures in the same order as input
Throws
BatchTransactionForwardingError When forwarding fails for any transaction in the batch
Throws
InvalidDelayArrayError When the delays array length does not match transactions.length - 1
Remarks
This overload submits transactions sequentially with variable delays between each submission. Each delay in the array corresponds to the wait time after forwarding the transaction at the same index.
Execution Flow:
- Send and confirm
transactions[0] - Wait
delaysMs[0]milliseconds - Send and confirm
transactions[1] - Wait
delaysMs[1]milliseconds - Continue for all transactions
The delaysMs array must have exactly transactions.length - 1 elements, as there is
one delay between each pair of transactions (no delay needed after the last transaction).
This is useful when you need different delays between different transactions, such as longer delays for more critical transactions or adaptive delays based on network conditions.
Example
const signedTxs = await signer.signTransactions(transactions);
// Variable delays: 200ms after first, 500ms after second, 300ms after third
const delays = [200, 500, 300];
const signatures = await forwarder.forwardTransactions(signedTxs, delays);Overrides
ITransactionForwarder.forwardTransactions
Call Signature
forwardTransactions(
transactions,offset,delayMs):Promise<string[]>
Defined in: src/client/implementation/connection-based-forwarder.ts:369
Forwards multiple signed transactions to the network starting from a specific offset with a fixed delay between each transaction.
Parameters
transactions
VersionedTransaction[]
Array of signed VersionedTransaction objects to forward
offset
number
The index in the array to start forwarding from (0-based). Transactions before this index are skipped.
delayMs
number
Fixed delay in milliseconds to wait between forwarding each transaction
Returns
Promise<string[]>
A promise resolving to an array of transaction signatures in the same order as the remaining transactions
Throws
BatchTransactionForwardingError When forwarding fails for any transaction in the batch or when offset is out of bounds
Remarks
This overload combines offset-based forwarding with a fixed delay between transactions.
Transactions before the offset are skipped, and the remaining transactions are forwarded
sequentially with a fixed delay between each. To forward without delay, pass 0 as delayMs.
Execution Flow:
- Skip transactions from index 0 to
offset - 1 - Send and confirm
transactions[offset] - Wait
delayMsmilliseconds (ifdelayMs > 0) - Send and confirm
transactions[offset + 1] - Wait
delayMsmilliseconds (ifdelayMs > 0) - Continue for all remaining transactions
The returned array contains results only for transactions starting from the offset.
For example, if offset = 2 and there are 5 transactions, only results for
transactions[2], transactions[3], and transactions[4] are returned.
Example
const signedTxs = await signer.signTransactions(transactions);
// Resume from index 2 with 500ms delay between each
const signatures = await forwarder.forwardTransactions(signedTxs, 2, 500);
// Or resume from index 3 without delay
const signatures = await forwarder.forwardTransactions(signedTxs, 3, 0);Overrides
ITransactionForwarder.forwardTransactions
Call Signature
forwardTransactions(
transactions,offset,delaysMs):Promise<string[]>
Defined in: src/client/implementation/connection-based-forwarder.ts:410
Forwards multiple signed transactions to the network starting from a specific offset with variable delays between transactions.
Parameters
transactions
VersionedTransaction[]
Array of signed VersionedTransaction objects to forward
offset
number
The index in the array to start forwarding from (0-based). Transactions before this index are skipped.
delaysMs
number[]
Array of delays in milliseconds between each transaction (must have length equal to remaining transactions minus 1)
Returns
Promise<string[]>
A promise resolving to an array of transaction signatures in the same order as the remaining transactions
Throws
BatchTransactionForwardingError When forwarding fails for any transaction in the batch or when offset is out of bounds
Throws
InvalidDelayArrayError When the delays array length does not match (transactions.length - offset) - 1
Remarks
This overload combines offset-based forwarding with variable delays between transactions. Transactions before the offset are skipped, and the remaining transactions are forwarded sequentially with variable delays between each.
Execution Flow:
- Skip transactions from index 0 to
offset - 1 - Send and confirm
transactions[offset] - Wait
delaysMs[0]milliseconds - Send and confirm
transactions[offset + 1] - Wait
delaysMs[1]milliseconds - Continue for all remaining transactions
The delaysMs array must have exactly (transactions.length - offset) - 1 elements,
as there is one delay between each pair of remaining transactions.
Example
const signedTxs = await signer.signTransactions(transactions);
// Resume from index 1 with variable delays: 200ms, 500ms, 300ms
const delays = [200, 500, 300];
const signatures = await forwarder.forwardTransactions(signedTxs, 1, delays);Overrides
ITransactionForwarder.forwardTransactions
getConnection()
getConnection():
Connection
Defined in: src/client/implementation/connection-based-forwarder.ts:158
Returns the underlying Solana Connection instance used by this forwarder.
Returns
Connection
The Connection instance.
fromConnection()
staticfromConnection(connection):ConnectionBasedForwarder
Defined in: src/client/implementation/connection-based-forwarder.ts:174
Creates a ConnectionBasedForwarder from an existing Connection instance.
Parameters
connection
Connection
The Solana Connection instance to use
Returns
ConnectionBasedForwarder
A new ConnectionBasedForwarder instance
Example
const connection = new Connection('https://api.mainnet-beta.solana.com');
const forwarder = ConnectionBasedForwarder.fromConnection(connection);fromRpcUrl()
staticfromRpcUrl(rpcUrl):ConnectionBasedForwarder
Defined in: src/client/implementation/connection-based-forwarder.ts:189
Creates a ConnectionBasedForwarder from an RPC URL.
Parameters
rpcUrl
string
The RPC endpoint URL (e.g., 'https://api.mainnet-beta.solana.com')
Returns
ConnectionBasedForwarder
A new ConnectionBasedForwarder instance
Example
const forwarder = ConnectionBasedForwarder.fromRpcUrl('https://api.mainnet-beta.solana.com');