NETSoon

Docs Start

Quickstart

Fund a key from the faucet, sign a transfer, send it 2-of-3 across a slot's three proposers and follow it to finality.

One script: a fresh key, a faucet grant, a transfer split three ways so no proposer can read it alone, and its trail to a final cblock.

  1. Install

    Put the two tarballs in vendor/ and install them with @solana/web3.js (Install the SDK).

    Terminal
    npm install ./vendor/acrux-contract-0.1.8.tgz ./vendor/acrux-sdk-0.1.0.tgz @solana/web3.js
  2. Write the script

    quickstart.ts
    import { ComputeBudgetProgram, Keypair, SystemProgram, Transaction } from '@solana/web3.js'
    import { createClient } from '@acrux/contract'
    import { connect } from '@acrux/sdk'
    
    const acrux = connect('http://127.0.0.1:4930')
    const api = createClient('http://127.0.0.1:4920')
    const payer = Keypair.generate()
    const address = payer.publicKey.toBase58()
    
    // 1. Fund the key from the faucet and wait until the grant is spendable.
    await api.faucet({ address })
    while (BigInt((await acrux.gateway.call('getBalance', { address })).spendableLamports) === 0n) {
      await new Promise((resolve) => setTimeout(resolve, 200))
    }
    
    // 2. Sign a transfer over Acrux Net's blockhash.
    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)
    
    // 3. Send it split three ways, readable from any two, and follow it to finality.
    const { id, targetSlot } = await acrux.send(tx, { n: 3, t: 2, signer: payer })
    console.log('sent', id, 'for slot', targetSlot)
    for await (const update of acrux.tx.follow(id)) {
      console.log(update.state, `${update.included} of ${update.threshold}`)
    }
  3. Run it

    Terminal
    node --experimental-strip-types quickstart.ts

    The script prints the transaction's ID and target slot, then one line per step of its trail. A run on Acrux Net:

    Output
    sent 06e0e0f94a39b6d35b764a9586fd6089b096c7bd6dc1fda03c2af54deeab9357 for slot 17185
    sent 0 of 2
    included 1 of 2
    executed 2 of 2
    finalized 2 of 2

    included comes once per fragment a proposer includes, executed when the second fragment makes the transaction readable, and finalized when its cblock is final.

What happened

StepWhere it is told
The faucet granted SOL and the demo pool's tokens to a new address, limited per key and per IP.POST /v1/faucet
latestBlockhash read the blockhash of Acrux Net's latest executed slot.getLatestBlockhash
send derived the public header, signed it with the fee payer, sealed three fragments and gave one to each proposer of a slot 200 ms ahead.Threshold sends
Each proposer included its fragment in its block without reading it, and sealed the block before seeing the others.Proposer, Hash exchange
Validators agreed on the set of blocks, rebuilt the transaction from two fragments, merged it into the slot's one order and executed it.Validator, Ordering
Four slots formed a cblock, which Alpenglow finalized.Consensus on cblocks

Open /tx/<id> on the site to see the same trail drawn slot by slot.

Next