Understanding Solana Jito Transactions with BundleOnly=True
When sending a single Jito transaction on the Solana blockchain, you face a common dilemma: how to bundle your transactions together while ensuring their integrity and security. One way to achieve this is to use the “bundleOnly” parameter in Jito transactions.
In this article, we will delve into the details of creating Jito transactions with bundleOnly “true”, focusing on what it means to be protected against reversals and MEV (mean time to exit).
What are Jito transactions?
Jito is a specific Solana transaction protocol that allows you to send multiple assets as a single transaction. This is especially useful when you need to transfer a small amount of one asset in exchange for another, as well as tip the network and leave a margin of potential profit (MEV).
What is bundleOnly=True?
When “bundleOnly=True”, Solana will attempt to create a bundle of your transactions. This means that if you send multiple resources with different transaction IDs or fuel prices, they will be combined into a single package.
Here is an example of what a linked Jito transaction might look like:
Jito {
input {
address = "0x1234567890abcdef"
gas price = 1000000
amount {
assetType = "token"
tokenAddress = "0x9876543210fedcba"
quantity = 10
}
}
output {
address = "0xabcdef12345"
gas price = 10,000
amount {
assetType = "token"
tokenAddress = "0x4567890123456789"
quantity = 20
}
}
}
In this example, we created a single Jito transaction with two input and two output resources.
Revert Protection
By default, Solana transactions are considered reversible. However, if you use the “bundleOnly=True” parameter, the bundled transaction will be considered irreversible. This means that if any individual input fails or is rejected by the network, the entire transaction will be rolled back.
To mitigate this risk, you can enable transaction reversal protection using the Solana JavaScript SDK function “revertProtect”.
const Jito = require('@solana/web3.js').Jito;
// Create a new Jito transaction with rollback protection
const transaction = new Jito({
input: [
{
address: "0x1234567890abcdef",
gas price: 1000000,
amount: {
assetType: 'token',
tokenAddress: '0x9876543210fedcba',
quantity: 10
}
},
{
address: "0x4567890123456789",
gas price: 10 000,
amount: {
assetType: 'token',
tokenAddress: '0x7654321098765432',
quantity: 20
}
}
],
output: [
{
address: "0xabcdef12345",
gas price: 10,000,
amount: {
assetType: 'token',
tokenAddress: '0x901234567890abcdef',
quantity: 30
}
}
]
});
// Perform the transaction
transaction.sign();
MEV protection
To further protect your linked transactions, you can use the `mevProtect' function to enable MEV protection. This will ensure that any potential profit from market fluctuations is protected.
Here is an example of how to create a MeV-protected Jito transaction:
“ javascript
const Jito = require(‘@solana/web3.js’).