πŸš€Achieve Best Performance for Landing a Transaction

To achieve the best performance for landing a singular transaction (landing speed and inclusion rate), your transaction should include a Priority Fee & a Tip.

When calling the submitting endpoint, do NOT use the frontRunningProtection option or there is a good chance that your transaction will be delayed. Make sure your transaction includes a good Priority Fee & a Tip. If you are not Enterprise-Elite or higher tier, your transaction is required to have a bloXroute memo instruction.

In addition, Trader API offers some additional parameters to enhance the propagation of your transactions, like staked connections. Your bloXroute subscription tier will also affect how many channels will be used for propagation, which affects the propagation time.

Follow the steps below for best practice for getting the optimal performance:

Priority fee

Make sure your transaction includes the priory fee by adding computePrice Instruction. You can use the Priority Fee Stream to get the current recommended priority fee.

const modifyComputeUnits = ComputeBudgetProgram.setComputeUnitLimit({ 
  units: 1000000 
});

const addPriorityFee = ComputeBudgetProgram.setComputeUnitPrice({ 
  microLamports: 1 
});

const transaction = new Transaction()
.add(modifyComputeUnits)
.add(addPriorityFee)
...
  );

tip Instruction

If you want to get the optimal performance you need to include a tip instruction. The Trader API service fee will be determined by the different features you will use (such as stacked connection, on-demand TPUs etc) so make sure to include a high enough tip.

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.

Submit the transaction

Submit your transaction to Trader API using the Submit Endpoint. Make sure frontRunningProtection is set to False.

For best performance and assuming you included a high enough tip and set useStakedRPC to True

curl -X 'POST' \
  'https://ny.solana.dex.blxrbdn.com/api/v2/submit' \
  -header "Authorization: $AUTH_HEADER" \
  -d '{
 "transaction": {"content": "AjF+Br2CUIENJqV1...BAAABCQ=="},
 "frontRunningProtection": false,
 "useStakedRPCs": true,
}'

If you are not an Elite or Ultra user, your transaction must include the bloXroute Memo Instruction.

Construct Memo Program Instruction by yourself

Our SDKs include hooks for adding this instruction for successful submission:

import "github.com/gagliardetto/solana-go"

// AddMemoToSerializedTxn adds memo instruction to a serialized transaction, it's primarily used if the user
// doesn't want to interact with Trader-API directly
func AddMemoToSerializedTxn(
	txBase64, 
	memoContent string,
	owner solana.PublicKey, 
	privateKeys map[solana.PublicKey]solana.PrivateKey
) (string, error) {}
	
// CreateTraderAPIMemoInstruction generates a transaction instruction that places a memo in the transaction log
// Having a memo instruction with signals Trader-API usage is required
func CreateTraderAPIMemoInstruction(msg string) solana.Instruction {}

If your language of choice is not included above, you can create an instruction referencing program HQ2UUt18uJqKaQFJhgV9zaTdQxUZjNrsKFgoEDquBkcx, with any data as the body. Make sure the memo_content is exactly "Powered by bloXroute Trader Api".

Last updated