Acton
Acton standard libraryTypes

transaction

transaction.tolk standard library file

Module defining transaction types.

This module provides a complete representation of TON transactions as they appear in the blockchain. It includes structures for all phases of transaction execution: storage, credit, compute, action, and bounce.

Examples:

val tx = results.at(0).tx.load();

// Check gas usage
val gas = tx.getUsedGas();
println("Gas used: {}", gas);

// Inspect account status change
val description = tx.description.load();
if (description is TlbTransOrd) {
    val compute = description.computePh;
    if (compute is TlbTrComputeVm) {
        println("VM exit code: {}", compute.exitCode);
    }
}

Definitions

TlbAccountStatus

enum TlbAccountStatus: uint2 {
    Uninitialized
    Frozen
    Active
    NonExisting
}

Type alias for transaction account status values used by TlbTransaction.origStatus and TlbTransaction.endStatus.

Source code

TlbDepthBalanceInfo

struct TlbDepthBalanceInfo {
    splitDepth: uint8 // #<= 30
    balance: TlbCurrencyCollection
}

Represents depth and balance information for split accounts.

Source code

TlbTransaction

struct (0b0111) TlbTransaction {
    /// Account address as 256-bit hash.
    accountAddr: bits256
    /// Logical time of the transaction.
    lt: uint64
    /// Hash of the previous transaction.
    prevTransHash: bits256
    /// Logical time of the previous transaction.
    prevTransLt: uint64
    /// Current time (Unix timestamp).
    now: uint32
    /// Number of outgoing messages.
    outmsgCnt: uint15
    /// Account status before transaction.
    origStatus: TlbAccountStatus
    /// Account status after transaction.
    endStatus: TlbAccountStatus
    /// In and out messages.
    messages: Cell<TlbTransactionMessages>
    /// Total fees collected.
    totalFees: TlbCurrencyCollection
    /// State update information.
    stateUpdate: Cell<TlbHashUpdate<TlbAccount>>
    /// Transaction description.
    description: Cell<TlbTransactionDescr>
}

Represents a transaction in the TON blockchain.

Source code

TlbTransaction.loadBody

fun TlbTransaction.loadBody<Msg>(self): Msg

Loads the in message body of the transaction with given type.

Fails if transaction has no inbound message (messages.inMsg is TlbNone), because this method unwraps it before typed decoding.

After an inbound message exists, if message type does not match Msg, loading fails with exit code 63. Internal and external-in transaction bodies are both supported.

Example:

val txs = net.send(address, msg);
val tx = txs.findTransaction<IncreaseCounter>({ to: address })!;
val body = tx.loadBody<IncreaseCounter>();
println(body.increaseBy);
Source code

TlbTransaction.loadInMsg

fun TlbTransaction.loadInMsg<Msg>(self): TlbMessage<Msg>

Loads the in message of the transaction with given type.

Fails if transaction has no inbound message (messages.inMsg is TlbNone), because this method unwraps it before typed decoding.

After an inbound message exists, if message type does not match Msg, loading fails with exit code 63. Internal and external-in transaction messages are both supported.

Source code

TlbTransaction.getUsedGas

fun TlbTransaction.getUsedGas(self): int

Returns consumed gas for ordinary transactions with VM compute phase.

Fails with Assert.fail:

Source code

TlbTransaction.getActionFee

fun TlbTransaction.getActionFee(self): coins?

Returns action-phase fee based on TlbTransaction.description variant.

Behavior by variant:

Source code

TlbTransaction.getAccountAddress

fun TlbTransaction.getAccountAddress(self, workchain: int = BASECHAIN): address

Return address of account of this transaction.

Source code

TlbTransactionMessages

struct TlbTransactionMessages {
    /// In message.
    inMsg: TlbMaybe<Cell<TlbMessageRelaxedGeneric>>
    /// Out messages.
    outMsgs: map<uint15, Cell<TlbMessageRelaxedGeneric>>
}
Source code

TlbMerkleUpdate

struct (0b0100) TlbMerkleUpdate<X> {
    /// Old hash.
    oldHash: bits256
    /// New hash.
    newHash: bits256
    /// Old depth.
    oldDepth: uint16
    /// New depth.
    newDepth: uint16
    /// Old value.
    old: X
    /// New value.
    new: X
}

Represents merkle update for proof-of-work.

Source code

TlbHashUpdate

struct (0b01110010) TlbHashUpdate<X> {
    /// Old hash.
    oldHash: bits256
    /// New hash.
    newHash: bits256
}

Represents simple hash update.

Source code

TlbMerkleProof

struct (0b0011) TlbMerkleProof<X> {
    /// Virtual hash.
    virtualHash: bits256
    /// Depth.
    depth: uint16
    /// Virtual root.
    virtualRoot: X
}

Represents merkle proof.

Source code

TlbHashUpdateType

type TlbHashUpdateType<X> = TlbMerkleUpdate<X> | TlbHashUpdate<X> | TlbMerkleProof<X>

Union type for hash updates.

Source code

TlbTrStoragePhase

struct TlbTrStoragePhase {
    /// Storage fees collected.
    storageFeesCollected: coins
    /// Storage fees due (if any).
    storageFeesDue: TlbMaybe<coins>
    /// Account status change.
    statusChange: TlbAccStatusChange
}

Represents storage phase of transaction processing.

Source code

TlbAccUnchanged

struct (0b0) TlbAccUnchanged
Source code

TlbAccFrozen

struct (0b10) TlbAccFrozen
Source code

TlbAccDeleted

struct (0b11) TlbAccDeleted
Source code

TlbAccStatusChange

type TlbAccStatusChange = TlbAccUnchanged | TlbAccFrozen | TlbAccDeleted
Source code

TlbTrCreditPhase

struct TlbTrCreditPhase {
    /// Due fees collected (if any).
    dueFeesCollected: TlbMaybe<coins>
    /// Credit amount.
    credit: TlbCurrencyCollection
}

Represents credit phase of transaction processing.

Source code

TlbTrComputeSkipped

struct (0b0) TlbTrComputeSkipped {
    reason: TlbComputeSkipReason
}

Represents compute phase of transaction processing.

Source code

TlbTrComputeVm

struct (0b1) TlbTrComputeVm {
    success: bool
    msgStateUsed: bool
    accountActivated: bool
    gasFees: coins
    data: Cell<TlbTrComputeVmRef>
}
Source code

TlbTrComputeVmRef

struct TlbTrComputeVmRef {
    gasUsed: TlbVarUint7
    gasLimit: TlbVarUint7
    gasCredit: TlbMaybe<TlbVarUint3>
    mode: int8
    exitCode: int32
    exitArg: TlbMaybe<int32>
    vmSteps: uint32
    vmInitStateHash: bits256
    vmFinalStateHash: bits256
}
Source code

TlbTrComputePhase

type TlbTrComputePhase = TlbTrComputeSkipped | TlbTrComputeVm

Union type for compute phases.

Source code

TlbCSkipNoState

struct (0b00) TlbCSkipNoState

Represents reasons for skipping computation.

Source code

TlbCSkipBadState

struct (0b01) TlbCSkipBadState
Source code

TlbCSkipNoGas

struct (0b10) TlbCSkipNoGas
Source code

TlbCSkipSuspended

struct (0b110) TlbCSkipSuspended
Source code

TlbComputeSkipReason

type TlbComputeSkipReason = TlbCSkipNoState | TlbCSkipBadState | TlbCSkipNoGas | TlbCSkipSuspended
Source code

TlbTrActionPhase

struct TlbTrActionPhase {
    success: bool
    valid: bool
    noFunds: bool
    statusChange: TlbAccStatusChange
    totalFwdFees: TlbMaybe<coins>
    totalActionFees: TlbMaybe<coins>
    resultCode: int32
    resultArg: TlbMaybe<int32>
    totActions: uint16
    specActions: uint16
    skippedActions: uint16
    msgsCreated: uint16
    actionListHash: bits256
    totMsgSize: TlbStorageUsed
}

Represents action phase of transaction processing.

Source code

TlbTrBounceNegfunds

struct (0b00) TlbTrBounceNegfunds

Represents bounce phase of transaction processing.

Source code

TlbTrBounceNofunds

struct (0b01) TlbTrBounceNofunds {
    msgSize: TlbStorageUsed
    reqFwdFees: coins
}
Source code

TlbTrBounceOk

struct (0b1) TlbTrBounceOk {
    msgSize: TlbStorageUsed
    msgFees: coins
    fwdFees: coins
}
Source code

TlbTrBouncePhase

type TlbTrBouncePhase = TlbTrBounceNegfunds | TlbTrBounceNofunds | TlbTrBounceOk

Union type for bounce phases.

Source code

TlbTransOrd

@overflow1023_policy("suppress")
struct (0b0000) TlbTransOrd {
    creditFirst: bool
    storagePh: TlbMaybe<TlbTrStoragePhase>
    creditPh: TlbMaybe<TlbTrCreditPhase>
    computePh: TlbTrComputePhase
    action: TlbMaybe<Cell<TlbTrActionPhase>>
    aborted: bool
    bounce: TlbMaybe<TlbTrBouncePhase>
    destroyed: bool
}

Represents ordinary transaction description.

Source code

TlbTransStorage

struct (0b0001) TlbTransStorage {
    storagePh: TlbTrStoragePhase
}

Represents storage transaction description.

Source code

TlbTransTickTock

@overflow1023_policy("suppress")
struct (0b001) TlbTransTickTock {
    isTock: bool
    storagePh: TlbTrStoragePhase
    computePh: TlbTrComputePhase
    action: TlbMaybe<Cell<TlbTrActionPhase>>
    aborted: bool
    destroyed: bool
}

Represents tick-tock transaction description.

Source code

TlbSplitMergeInfo

struct TlbSplitMergeInfo {
    curShardPfxLen: uint8 // ## 6
    accSplitDepth: uint8  // ## 6
    thisAddr: bits256
    siblingAddr: bits256
}

Represents split-merge information.

Source code

TlbTransSplitPrepare

@overflow1023_policy("suppress")
struct (0b0100) TlbTransSplitPrepare {
    splitInfo: TlbSplitMergeInfo
    storagePh: TlbMaybe<TlbTrStoragePhase>
    computePh: TlbTrComputePhase
    action: TlbMaybe<Cell<TlbTrActionPhase>>
    aborted: bool
    destroyed: bool
}

Represents split prepare transaction description.

Source code

TlbTransSplitInstall

struct (0b0101) TlbTransSplitInstall {
    splitInfo: TlbSplitMergeInfo
    prepareTransaction: Cell<TlbTransaction>
    installed: bool
}

Represents split install transaction description.

Source code

TlbTransMergePrepare

struct (0b0110) TlbTransMergePrepare {
    splitInfo: TlbSplitMergeInfo
    storagePh: TlbTrStoragePhase
    aborted: bool
}

Represents merge prepare transaction description.

Source code

TlbTransMergeInstall

@overflow1023_policy("suppress")
struct (0b0111) TlbTransMergeInstall {
    splitInfo: TlbSplitMergeInfo
    prepareTransaction: Cell<TlbTransaction>
    storagePh: TlbMaybe<TlbTrStoragePhase>
    creditPh: TlbMaybe<TlbTrCreditPhase>
    computePh: TlbTrComputePhase
    action: TlbMaybe<Cell<TlbTrActionPhase>>
    aborted: bool
    destroyed: bool
}

Represents merge install transaction description.

Source code

TlbTransactionDescr

type TlbTransactionDescr =
    | TlbTransOrd
    | TlbTransStorage
    | TlbTransTickTock
    | TlbTransSplitPrepare
    | TlbTransSplitInstall
    | TlbTransMergePrepare
    | TlbTransMergeInstall

Union type for all transaction descriptions.

Source code

TlbVarUint7

type TlbVarUint7 = int
Source code

TlbVarUint7.packToBuilder

fun TlbVarUint7.packToBuilder(self, mutate b: builder): void
Source code

TlbVarUint7.unpackFromSlice

fun TlbVarUint7.unpackFromSlice(mutate s: slice): TlbVarUint7
Source code

TlbVarUint3

type TlbVarUint3 = int
Source code

TlbVarUint3.packToBuilder

fun TlbVarUint3.packToBuilder(self, mutate b: builder): void
Source code

TlbVarUint3.unpackFromSlice

fun TlbVarUint3.unpackFromSlice(mutate s: slice): TlbVarUint3
Source code

TlbStorageUsed

struct TlbStorageUsed {
    cells: TlbVarUint7
    bits: TlbVarUint7
}

Represents storage used information.

Source code

TlbStorageExtraNone

struct (0b000) TlbStorageExtraNone

Represents storage extra information.

Source code

TlbStorageExtraDict

struct (0b001) TlbStorageExtraDict {
    dictHash: uint256
}
Source code

TlbStorageExtraInfo

type TlbStorageExtraInfo = TlbStorageExtraNone | TlbStorageExtraDict

Union type for storage extra information.

Source code

TlbStorageInfo

struct TlbStorageInfo {
    /// Storage used.
    used: TlbStorageUsed
    /// Storage extra information.
    storageExtra: TlbStorageExtraInfo
    /// Last paid time.
    lastPaid: uint32
    /// Due payment (optional).
    duePayment: TlbMaybe<coins>
}

Represents storage information.

Source code

TlbAccountNone

struct (0b0) TlbAccountNone

Represents account.

Source code

TlbAccountInfo

struct (0b1) TlbAccountInfo {
    /// Account address.
    addr: address
    /// Storage statistics.
    storageStat: TlbStorageInfo
    /// Account storage.
    storage: TlbAccountStorage
}
Source code

TlbAccount

type TlbAccount = TlbAccountNone | TlbAccountInfo

Union type for account.

Source code

TlbAccountStateUninit

struct (0b00) TlbAccountStateUninit

Account state in TlbAccountStorage (block.tlb AccountState).

Source code

TlbAccountStateActive

struct (0b1) TlbAccountStateActive {
    stateInit: StateInit
}
Source code

TlbAccountStateFrozen

struct (0b01) TlbAccountStateFrozen {
    stateHash: uint256
}
Source code

TlbAccountState

type TlbAccountState = TlbAccountStateUninit | TlbAccountStateActive | TlbAccountStateFrozen

Union type for account storage state.

Source code

TlbAccountStorage

struct TlbAccountStorage {
    /// Last transaction logical time.
    lastTransLt: uint64
    /// Account balance.
    balance: TlbCurrencyCollection
    /// Account state.
    state: TlbAccountState
}

Represents account storage.

Source code

TlbShardAccount

struct TlbShardAccount {
    account: Cell<TlbAccount>
    lastTransHash: uint256
    lastTransLt: uint64
}

Represents a shard account state.

Source code

Last updated on

On this page