NETSoon

Docs SDK

Send a transaction

Sign a Solana transaction over Acrux Net's blockhash and send it into a slot with @acrux/sdk.

An Acrux transaction is a signed Solana transaction. send reads its public header from the signed bytes, picks the target slot and the receiving proposers, and submits it.

Sign over the net's blockhash

Acrux Net executes in its own SVM, so a transaction carries the net's blockhash, not a Solana cluster's. Any blockhash of the last 1,200 slots, one minute, is accepted; latestBlockhash() returns one from 8 slots back, which every validator already holds.

send.ts
import { ComputeBudgetProgram, Keypair, SystemProgram, Transaction } from '@solana/web3.js'
import { connect } from '@acrux/sdk'

const acrux = connect('http://127.0.0.1:4930')
const payer = Keypair.generate() // funded from the faucet, see the Quickstart

const { blockhash } = await acrux.latestBlockhash()
const tx = new Transaction({ feePayer: payer.publicKey, recentBlockhash: blockhash }).add(
  ComputeBudgetProgram.setComputeUnitLimit({ units: 20_000 }),
  ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 100 }),
  SystemProgram.transfer({ fromPubkey: payer.publicKey, toPubkey: Keypair.generate().publicKey, lamports: 10_000 }),
)
tx.sign(payer)

const { id, targetSlot } = await acrux.send(tx)

send returns as soon as the gateway admits the transaction:

FieldMeaning
idthe transaction's ID: SHA-256 of its signed message, lowercase hex. Follow it with tx.follow(id) or getTransaction.
targetSlotthe slot the transaction was sent for

What send does

  1. Reads the header

    From the signed bytes it derives the public TxHeader: the ID, the fee payer, the priority fee per compute unit and the compute limit from the Compute Budget instructions, and the writable accounts. Without a compute-limit instruction the limit is 200,000 CU per instruction, at most 1,400,000.

  2. Picks the slot

    The target slot is four slots after the latest started slot, 200 ms ahead.

  3. Picks the receivers

    It reads the window that holds the target slot and sends to its online proposers first, n of them.

  4. Submits

    With t = 1 it calls submitTransaction once with the signed bytes and the list of receivers. With t of 2 or 3 it seals the transaction into fragments and calls submitFragment once per receiver (Threshold sends).

Options

ts
await acrux.send(tx, { n, t, signer })
OptionTypeDefaultMeaning
n1, 2 or 31how many of the target slot's three proposers receive it
t1, 2 or 3, at most n1how many of them must include it before anyone can read it
signerKeypair or (message: Uint8Array) => Uint8Array | Promise<Uint8Array>the fee payer, required when t is 2 or 3
CallWhat is sent
send(tx)the signed transaction to one proposer
send(tx, { n: 2 })the signed transaction to two proposers; either lands it
send(tx, { n: 3 })the signed transaction to all three proposers
send(tx, { n: 3, t: 2, signer })three encrypted fragments, readable from any two
send(tx, { n: 3, t: 3, signer })three encrypted fragments, readable only from all three

Fees

Each proposer that includes a copy or a fragment charges the inclusion fee, 1000 lamports lamports, so n copies cost n inclusion fees. The base fee and the priority fee are charged once, at execution. Fees and the reserve

The fee payer keeps a reserve of 0.001 SOL SOL that a send cannot spend; getBalance returns spendableLamports after it.

Sending again

The target slot must not have started when the gateway admits the send. If it has, send throws TRANSACTION_EXPIRED: sign over a fresh blockhash and send again (Errors). Sending the same signed transaction again for the same slot is idempotent.