πŸ›‘οΈFront-Running Protection & Transaction Bundle

Trader API offers Front-Running Protection & Transaction Bundling service. Your transaction or the last transaction inside a batch must include an tip instruction to use such services.

An tip instruction is an optional parameter when you build a transaction using bloXroute Trader API. Searches/Traders can also construct their own transactions and add the bloXroute tip instruction as listed on the button on this page.

When submitting a batch, the last transaction must contain the tip instruction. You can also create an entirely new transaction for paying tip alone, in case the transaction is too big to include extra instruction.


Front-running protection.

Submit a transaction with the parameter'frontRunningProtection' set to True when calling the Submit endpoint.

Transaction Bundle.

To send the set of transactions as a bundle set the parameter'useBundle' to True when calling the Batch Submit endpoint. Bundles are a list of transactions that execute sequentially and atomically, all-or-nothing. To explain more:

  • Sequentially: provide a list of transactions in a bundle and they are guaranteed to execute in order.

  • Atomically: bundles execute atomically within the same slot. A bundle can't cross slot boundaries and if the entire thing executes successfully, it will all be committed to the chain.

  • All-or-nothing: bundles can only contain successful transactions. If any transaction in a bundle fails, no transactions in the bundle will make it on-chain.


How is the fee calculated?

Our Trader API charges a small percentage of the tip as the service fee.

Using the Front-Running Protection service requires 2 - 5% of the total tip amount (based on your bloXroute account tier)as the service fee. Setting a higher tip will yield a faster inclusion.

Account TierTip Service Fee

Ultra

2%

Enterprise-Elite

2%

Enterprise

4%

Professional

5%

Introductory

5%

A minimum tipis 2,000,000 Lamports (0.002 SOL) as of this writing (06/13/2024)

Using the Transaction Bundle service requires a percentage of the total tip, which is calculated using the following formula, as the service fee. The maximum number of transactions in one bundle is 4.

For each transaction in a bundle, 5% of the total tip is charged as a fee. Ex. a batch with 2 transactions will be charged 10%. (Introductory tier)

A minimum tipis 2,000,000 Lamports (0.002 SOL) as of this writing (06/13/2024)

Construct tip Instruction by Yourself

If you want to construct your transactions without using the Trader API endpoints and with Front-Running Protection or Transaction Bundle you must include the tip instructions. The code example is shown below.

import (
	"github.com/gagliardetto/solana-go"
	"github.com/gagliardetto/solana-go/programs/system"
)

const (
	// BloxrouteTipAddress is from here and may fall out of date from time to time. Check our docs:
	// https://docs.bloxroute.com/solana/trader-api-v2/front-running-protection-and-transaction-bundle
	BloxrouteTipAddress = "HWEoBxYs7ssKuudEjzjmpfJVX7Dvi7wescFsVx2L5yoY"
)

// CreateBloxrouteTipTransactionToUseBundles creates a transaction you can use to when using PostSubmitBundle endpoints.
// This transaction should be the LAST transaction in your submission bundle
func CreateBloxrouteTipTransactionToUseBundles(privateKey solana.PrivateKey, tipAmount uint64, recentBlockHash solana.Hash) (*solana.Transaction, error) {
	recipient := solana.MustPublicKeyFromBase58(BloxrouteTipAddress)

	tx, err := solana.NewTransaction([]solana.Instruction{
		system.NewTransferInstruction(tipAmount, privateKey.PublicKey(), recipient).Build()}, recentBlockHash)
	if err != nil {
		return nil, err
	}

	signatures, err := tx.Sign(func(key solana.PublicKey) *solana.PrivateKey {
		if key.Equals(privateKey.PublicKey()) {
			return &privateKey
		}
		return nil
	})
	if err != nil {
		return nil, err
	}

	tx.Signatures = signatures

	return tx, nil
}

If your language of choice is not included above, you can create an instruction referencing our tip-receiving address: HWEoBxYs7ssKuudEjzjmpfJVX7Dvi7wescFsVx2L5yoY.

Last updated