Solana: Jito Transaction Bundle Only with V2. Parameter?
=======================================================================
As of Solana 1.13, you can send multiple transactions within a single bundle as long as certain conditions are met. In this article, we will explore how to use the bundleOnly=true
parameter when sending a transaction on Solana.
What is a Jito Transaction?
——————————
A Jito transaction is an optimized transaction type that allows for efficient and secure transfer of assets across multiple accounts. It was introduced in Solana 1.8 as a replacement for the old transfer
function. A Jito transaction consists of multiple transactions, each with its own set of data.
Bundle Transactions
———————-
A bundle transaction is an optimized way to send multiple transactions within a single transaction. This allows for significant efficiency gains compared to sending individual transactions one after the other.
The BundleOnly Parameter
—————————–
When sending a transaction as a bundle on Solana, you can specify the bundleOnly
parameter with a value of true
. Here’s an example:
use solana-program::account_info;
// Create two account info objects for sender and receiver accounts
let sender_account_info = account_info::new(
"sender".to_string(),
0,
1, // sender account index
);
let receiver_account_info = account_info::new(
"receiver".to_string(),
0,
1, // receiver account index
);
// Create a Jito transaction with bundleOnly=true and type
let jito_transaction = solana_program::transaction::Builder::new()
.set_account_info(sender_account_info)
.set_account_info(receiver_account_info)
.set_tag("JitoTransaction")
.set_tag("BundleOnly=true")
.with_packed_bytes(
solana_program::packed_array::array(
// Add Jito transactions as individual bytes
solana_program::packed_array::new(
account_info::new(
"transaction1".to_string(),
0,
1, // transaction index
),
account_info::new(
"transaction2".to_string(),
0,
1, // transaction index
)
),
)
);
// Send the Jito transaction as a bundle
let result = solana_program::program::send_jito_transaction(&jito_transaction);
MeV Protection
——————
By default, Solana transactions do not provide MeV (Maximum Ether) protection. However, you can enable MeV protection for your Jito transaction by adding the mev_protection=true
parameter to the transaction data:
“`sol
let jito_transaction = solana_program::transaction::Builder::new()
.set_account_info(sender_account_info)
.set_account_info(receiver_account_info)
.set_tag(“JitoTransaction”)
.set_tag(“BundleOnly=true”)
.with_packed_bytes(
solana_program::packed_array::array(
// Add Jito transactions as individual bytes
solana_program::packed_array::new(
account_info::new(
“transaction1”.to_string(),
0,
1, // transaction index
),
account_info::new(
“transaction2”.to_string(),
0,
1, // transaction index
)
),
// Add MeV protection bytes
solana_program::packed_array::new(
account_info::new(
“mev_protection_bytes”.