LoadBalancer<SolanaRpcClient> loadBalancer; // See LoadBalancer in Ravina Corevar rpcCallWeights = CallWeights.createDefault();var executorService = Executors.newVirtualThreadPerTaskExecutor();var rpcCaller = new RpcCaller(executorService, loadBalancer, rpcCallWeights);var getEpochInfoCallContext = CallContext.createContext( 1, // Call weight. 0, // Minimum capacity required before sending. 1, // Maximum times to try to claim capacity. true, // Eventually force the call. 0, // Maximum times to retry call. true // Measure the call time to be tracked by the load balancer for prioritizing items.);var epochInfo = rpcCaller.courteousGet( SolanaRpcClient::getEpochInfo, getEpochInfoCallContext, "rpcClient::getEpochInfo");
Used to manage the connection of a SolanaRpcWebsocket. Call checkConnection to drive re-connections. If errors are
observed, the corresponding delay from the provided Backoff will be respected.
May be used to dynamically fetch lookup tables. Ideally used in conjunction with a websocket to maintain the latest view of a table.
The current implementation only removes tables if they are no longer active or no longer exist on-chain.
Provides functionality for tracking transaction confirmation via asynchronous and polling signature status RPC calls.
Up to 256 transaction signatures are checked for each polling call.
It is recommended to use this with the Instruction or Batch Instruction Services, rather than directly.
Handles transaction simulation, creation, and confirmation/expiration monitoring.The transaction is simulated against a Confirmed state.The blockhash and its height is taken from the simulation result to enable expiration tracking.After sending a transaction, a confirmed state signature status Web Socket subscription is made, which expires based on the Transaction Monitor configuration.If a response message is received over the Web Socket and a finalized state is desired an additional subscription is made, which expires two times the estimated duration of 32 blocks.If the Web Socket subscriptions time out the service falls back to polling signature status calls.
The monitor will make at least one call without transaction history and optionally continue to do so until the transactions’ block has expired.
After which one final call is made with transaction history enabled to ensure the transaction did not land but was expired from the recent history cache.While waiting for expiration the transaction may optionally be re-sent based on the Transaction Monitor configuration.
// See the documentation above for construction of these components.EpochInfoService epochInfoService;RpcCaller rpcCaller;TransactionProcessor transactionProcessor;TxMonitorService txMonitorService;var nativeProgramClient = NativeProgramClient.createClient();var instructionService = InstructionService.createService( rpcCaller, transactionProcessor, nativeProgramClient, epochInfoService, txMonitorService);// Populated from the Jupiter API.List<Instruction> jupiterSwapInstructions;List<PublicKey> lookupTableKeys;var maxSOLPriorityFee = new BigDecimal("0.001");var maxLamportPriorityFee = LamportDecimal.fromBigDecimal(maxSOLPriorityFee);var transactionResult = instructionService.processInstructions( 1.1, // Compute budget multiplier applied against simulation consumption. jupiterSwapInstructions, maxLamportPriorityFee, // Caps the priority fee from the Transaction Processor's Fee Provider. FINALIZED, // Await finalization if successful. CONFIRMED, // Only await confirmed if fails, e.g., slippage exceeded. true, // Verify expired, if the network is not aware of the transaction wait 151 blocks to ensure it cannot be applied. true, // Continue to re-send the transaction based on the Transaction Monitor configuration. 0, // Number of times to re-construct the transaction with a new block hash after expiration. transactionProcessor.transactionFactory(lookupTableKeys), // Uses an internal address lookup table cache. "jupiter swap" // log context.);
Extends the Instruction Service functionality by dynamically batching multiple instructions which may exceed the size of a single transaction into multiple transactions.