Getting started
Build, sign, and encode a QU transfer transaction from scratch.
Import the transaction pipeline
import { buildTransaction, signTransaction, encodeTransaction } from "@qubic.org/tx"
import { publicKeyFromSeed, identityToPublicKey } from "@qubic.org/crypto"
import { toSeed, toIdentity } from "@qubic.org/types"Prepare keys
const seed = toSeed("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
const sourcePublicKey = await publicKeyFromSeed(seed)
const destinationPublicKey = identityToPublicKey(
toIdentity("CFBMEMZOIDEXQAUXYYSZIURADQLAPWPMNJXQSNVQZAHYVOPYUKKJBJUCTVJL")
)Build, sign, and encode
const unsigned = buildTransaction({
sourcePublicKey,
destinationPublicKey,
amount: 1_000_000n,
targetTick: 18500000, // use live.getTickInfo() for the real tick
inputType: 0,
})
const signed = await signTransaction(unsigned, seed)
const encoded = encodeTransaction(signed)
console.log("Encoded transaction:", encoded)
// Pass `encoded` to live.broadcastTransaction(encoded) from @qubic.org/rpcbuildTransaction and encodeTransaction are synchronous. Only signTransaction is async — it calls sign from @qubic.org/crypto internally. Always await it before encoding.