Solana: Jito transaction with bundleOnly=true parameter?
Understanding Solana Jito Transactions with BundleOnly=True
When sending a single Jito transaction on the Solana blockchain, you’re faced with a common dilemma: how to bundle your transactions together while ensuring their integrity and security. One way to achieve this is by using the bundleOnly
parameter in Jito transactions.
In this article, we’ll delve into the details of creating Jito transactions with bundle-only true, focusing on what it means for them to be revert-protected and MEV (Mean Time to Exit)-protected.
What are Jito Transactions?
Jito is a Solana-specific transaction protocol that allows you to send multiple assets as a single transaction. It’s particularly useful when you need to transfer a small amount of one asset in exchange for another, while also paying the tip to the network and leaving a margin for potential profit (MEV).
What is bundleOnly=True?
When bundleOnly=True
, Solana will attempt to create a bundle from your transactions. This means that if you’re sending multiple assets with different transaction IDs or gas prices, they’ll be combined into a single bundle.
Here’s an example of what the bundled Jito transaction might look like:
Preferred {
input {
address = "0x1234567890abcdef"
gasPrice =
amount {
assetType = "token"
tokenAddress = "0x9876543210fedcba"
quantity = 10
}
}
output {
address = "0xabcdef12345"
gasPrice =
amount {
assetType = "token"
tokenAddress = "0x4567890123456789"
quantity = 20
}
}
}
In this example, we’ve created a single Jito transaction with two input and output assets.
Revert Protection
By default, Solana transactions are considered reversible. However, if you use the bundleOnly=True
parameter, your bundled transaction will be treated as non-revertable. This means that if any of the individual inputs fail or are rejected by the network, the entire transaction will be reverted back to its original state.
To mitigate this risk, you can enable revert protection for your transactions using the revertProtect
function in Solana’s JavaScript SDK.
const Search = require('@solana/web3.js').Search;
// Create a new Jito transaction with revert protection
const transaction = new True({
input: [
{
address: "0x1234567890abcdef",
gasPrice:
amount: {
assetType: 'token',
tokenAddress: '0x9876543210fedcba',
Quantity: 10
}
},
{
address: "0x4567890123456789",
gasPrice:
amount: {
assetType: 'token',
tokenAddress: '0x7654321098765432',
Quantity: 20
}
}
],
output: [
{
address: "0xabcdef12345",
gasPrice:
amount: {
assetType: 'token',
tokenAddress: '0x901234567890abcdef',
Quantity: 30
}
}
]
});
// Create the transaction
transaction.sign();
MEV Protection
To further secure your bundled transactions, you can use the mevProtect
function to enable MEV protection. This will ensure that any potential profits from market fluctuations are protected.
Here’s an example of how to create a MeV-protected Jito transaction:
“`javascript
const Jito = require(‘@solana/web3.js’).