QubicTypeScript

Transfers & contract calls

buildTransfer and buildScTransaction — high-level signed transaction builders.

Both methods return { encoded, hash }: encoded is the base64 transaction ready to broadcast; hash is the canonical TxHash.

wallet.buildTransfer(params)

Builds and signs a QU transfer.

import { createWallet, generateSeed } from "@qubic.org/wallet"
import { createLiveClient } from "@qubic.org/rpc"
import { toIdentity } from "@qubic.org/types"

const live = createLiveClient()
const wallet = createWallet(generateSeed())
const { tick } = await live.getTickInfo()

const { encoded, hash } = await wallet.buildTransfer({
  destination: toIdentity("CFBMEMZOIDEXQAUXYYSZIURADQLAPWPMNJXQSNVQZAHYVOPYUKKJBJUCTVJL"),
  amount: 1_000_000n,
  targetTick: tick + 5,
  currentTick: tick,
})

await live.broadcastTransaction(encoded)
console.log("TX hash:", hash)

Parameters

NameTypeRequiredDescription
destinationIdentityYesRecipient identity
amountbigintYesQU to send
targetTicknumberYesTick by which node must process the TX
currentTicknumberYesCurrent tick (used for expiry validation)

Returns Promise<{ encoded: Base64, hash: TxHash }>


wallet.buildScTransaction(params)

Builds and signs a smart contract procedure call.

import { qearn } from "@qubic.org/contracts"
import { toIdentity } from "@qubic.org/types"

const destination = toIdentity("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")

const { encoded, hash } = await wallet.buildScTransaction({
  destination,
  amount: 10_000_000n,
  targetTick: tick + 5,
  currentTick: tick,
  inputType: qearn.LOCK_INPUT_TYPE,
  payload: qearn.buildLockInput({ amount: 10_000_000n }),
})

The destination for all SC calls is the 60-character all-A identity (the zero address). Each contract is identified by its inputType, not by address.

Parameters

NameTypeRequiredDescription
destinationIdentityYesZero identity (AAAA...)
amountbigintYesQU attached to the call (0n for read-only procedures)
targetTicknumberYesTick deadline
currentTicknumberYesCurrent tick
inputTypenumberYesProcedure input type constant
payloadUint8ArrayYesEncoded procedure input

Returns Promise<{ encoded: Base64, hash: TxHash }>


wallet.identity

The Qubic identity derived from the wallet's seed. Read-only.

const wallet = createWallet(seed)
console.log(wallet.identity) // Identity — 60 uppercase chars

wallet.publicKey

The 32-byte FourQ public key derived from the wallet's seed. Useful for low-level TCP calls.

const pk: Uint8Array = wallet.publicKey

On this page