tx_engine
Tx engine for sending tx with optmized mechanism.
How to start
In cargo.toml:
[]
...
="0.1.0"
In main.rs:
use noierrdev_antoine_tx_engine as tx_engine;
...
let mut tx_meta_pool : = new;
let tx_meta_pool_monitor=clone;
let tx_meta_pool_engine = clone;
let rpc_client = new;
let http_client=new;
...
let tx_engine=new;
How to add ComputeBudget Program instructions for optimization and priority
let instruction_set_compute_unit_price : Instruction = build_compute_unit_price_instruction;
let instruction_set_compute_unit_limit : Instruction = build_compute_unit_limit_instruction;
Adding tip instruction
You can add tip instruction of any landing provider of astralane, jito, 0slot, temperal, blockrazor, flashblock, node1 and also helius!!
...
let tip_0slot_instruction = build_zero_slot_tip_instruction;
let tip_astralane_instruction = build_astralane_tip_instruction;
...
You can add any tip address of any landing provider with simple function.
...
let tip_instruction = build_tip_instruction;
let tip_tx = build_tip_tx;
...
Refreshing recent_blockhash in background
After creation of tx_engine instance, it runs simple task in background to refresh recent_blockhash property.
You can use that as recent_blockhash of tx so that you can save one rpc api call while building transaction.
let recent_blockhash : Hash= get_blockhash;
Building Transaction
You can build transaction as VersionedTransaction and sign from instructions.
let tx : VersionedTransaction = build_tx_from_ix;
You can add tip instruction with passing arguement into function.
let tx : VersionedTransaction =build_tx;
Submitting tx or bundle
Transaction
You can submit transaction via tx_engine's rpc client or http client instance.
let tx_hash : String = send_rpc_versioned;
let tx_hash : String = send_url_versioned.await;
Or, you can submit using external rpc client or http client.
let tx_hash : String = send_rpc_versioned;
let tx_hash : String = send_url_versioned.await;
Recently, 0slot or Astralane strated supporting optimized endpoint without JSON parsing(Please note that there is no returning value).
send_url_text.await;
send_url_text.await;
If you configured batch_sender_url which supports sendTransactionBatch when initialize tx_engine instance, you can send batch txs via that.
send_batch.await;
Sending with durable nonce
You can send single tx using durable nonce account via several landing providers. Only first tx which is processed is valid and others will be failed.
Please note that you need to use binary sender url for astralane and 0slot.
Sending tx as binary on astralane
send_with_durable_nonce;
Sending with returning metadata
You can send tx and wait for tx metadata after processed with just running single method.
let tx_metadata : Value = send_for_tx_meta.await;
Sending to multiple endpoints without tip
tx_engine.send_tx_multiple_urls.await;
Sending Bundle
You can send bundle via jito or astralane endpoint which were configured when you initialize tx_engine instance.
send_jito_bundle.await;
send_astralane_bundle.await;
Sequential landing
That is the most amazing part of this engine.
You can send batch txs using this method and tx_engine will send txs one by one but if one is failed then stop sending immediately.
Please note that this is not atomic processing and not bundles.
Currently, it uses single_sender_url.
But in the future, I will add more customizable function.
It workes only when grpc monitor is working properly.
...
let mut tx_pool : = new;
let tx_pool_monitor=clone;
let tx_pool_engine = clone;
...
let monitor_task = spawn;
tasks.push;
...
send_sequential.await;
Using durable nonce
You can get instructions to create durable nonce account.
let create_nonce_instructions : = build_create_nonce_account_instruction;
Or, you can get signed tx to create durable nonce account.
let create_nonce_tx : VersionedTransaction = build_create_nonce_account_tx;
Also you can get nonce hash from address of nonce account.
let nonce_hash : Hash = get_nonce;