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 codeTlbDepthBalanceInfo
struct TlbDepthBalanceInfo {
splitDepth: uint8 // #<= 30
balance: TlbCurrencyCollection
}Represents depth and balance information for split accounts.
Source codeTlbTransaction
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 codeTlbTransaction.loadBody
fun TlbTransaction.loadBody<Msg>(self): MsgLoads 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);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.
TlbTransaction.getUsedGas
fun TlbTransaction.getUsedGas(self): intReturns consumed gas for ordinary transactions with VM compute phase.
Fails with Assert.fail:
- if
descriptionis not TlbTransOrd; - if
description.computePhis TlbTrComputeSkipped.
TlbTransaction.getActionFee
fun TlbTransaction.getActionFee(self): coins?Returns action-phase fee based on TlbTransaction.description variant.
Behavior by variant:
- TlbTransOrd and TlbTransTickTock with present
action: returnsaction.totalActionFees.unwrapOr(null); - TlbTransOrd and TlbTransTickTock with
action = TlbNone: returnsnull; - all other TlbTransactionDescr variants: returns
null.
TlbTransaction.getAccountAddress
fun TlbTransaction.getAccountAddress(self, workchain: int = BASECHAIN): addressReturn address of account of this transaction.
Source codeTlbTransactionMessages
struct TlbTransactionMessages {
/// In message.
inMsg: TlbMaybe<Cell<TlbMessageRelaxedGeneric>>
/// Out messages.
outMsgs: map<uint15, Cell<TlbMessageRelaxedGeneric>>
}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 codeTlbHashUpdate
struct (0b01110010) TlbHashUpdate<X> {
/// Old hash.
oldHash: bits256
/// New hash.
newHash: bits256
}Represents simple hash update.
Source codeTlbMerkleProof
struct (0b0011) TlbMerkleProof<X> {
/// Virtual hash.
virtualHash: bits256
/// Depth.
depth: uint16
/// Virtual root.
virtualRoot: X
}Represents merkle proof.
Source codeTlbHashUpdateType
type TlbHashUpdateType<X> = TlbMerkleUpdate<X> | TlbHashUpdate<X> | TlbMerkleProof<X>Union type for hash updates.
Source codeTlbTrStoragePhase
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 codeTlbAccUnchanged
struct (0b0) TlbAccUnchangedTlbAccFrozen
struct (0b10) TlbAccFrozenTlbAccDeleted
struct (0b11) TlbAccDeletedTlbAccStatusChange
type TlbAccStatusChange = TlbAccUnchanged | TlbAccFrozen | TlbAccDeletedTlbTrCreditPhase
struct TlbTrCreditPhase {
/// Due fees collected (if any).
dueFeesCollected: TlbMaybe<coins>
/// Credit amount.
credit: TlbCurrencyCollection
}Represents credit phase of transaction processing.
Source codeTlbTrComputeSkipped
struct (0b0) TlbTrComputeSkipped {
reason: TlbComputeSkipReason
}Represents compute phase of transaction processing.
Source codeTlbTrComputeVm
struct (0b1) TlbTrComputeVm {
success: bool
msgStateUsed: bool
accountActivated: bool
gasFees: coins
data: Cell<TlbTrComputeVmRef>
}TlbTrComputeVmRef
struct TlbTrComputeVmRef {
gasUsed: TlbVarUint7
gasLimit: TlbVarUint7
gasCredit: TlbMaybe<TlbVarUint3>
mode: int8
exitCode: int32
exitArg: TlbMaybe<int32>
vmSteps: uint32
vmInitStateHash: bits256
vmFinalStateHash: bits256
}TlbTrComputePhase
type TlbTrComputePhase = TlbTrComputeSkipped | TlbTrComputeVmUnion type for compute phases.
Source codeTlbCSkipNoState
struct (0b00) TlbCSkipNoStateRepresents reasons for skipping computation.
Source codeTlbCSkipBadState
struct (0b01) TlbCSkipBadStateTlbCSkipNoGas
struct (0b10) TlbCSkipNoGasTlbCSkipSuspended
struct (0b110) TlbCSkipSuspendedTlbComputeSkipReason
type TlbComputeSkipReason = TlbCSkipNoState | TlbCSkipBadState | TlbCSkipNoGas | TlbCSkipSuspendedTlbTrActionPhase
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 codeTlbTrBounceNegfunds
struct (0b00) TlbTrBounceNegfundsRepresents bounce phase of transaction processing.
Source codeTlbTrBounceNofunds
struct (0b01) TlbTrBounceNofunds {
msgSize: TlbStorageUsed
reqFwdFees: coins
}TlbTrBounceOk
struct (0b1) TlbTrBounceOk {
msgSize: TlbStorageUsed
msgFees: coins
fwdFees: coins
}TlbTrBouncePhase
type TlbTrBouncePhase = TlbTrBounceNegfunds | TlbTrBounceNofunds | TlbTrBounceOkUnion type for bounce phases.
Source codeTlbTransOrd
@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 codeTlbTransStorage
struct (0b0001) TlbTransStorage {
storagePh: TlbTrStoragePhase
}Represents storage transaction description.
Source codeTlbTransTickTock
@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 codeTlbSplitMergeInfo
struct TlbSplitMergeInfo {
curShardPfxLen: uint8 // ## 6
accSplitDepth: uint8 // ## 6
thisAddr: bits256
siblingAddr: bits256
}Represents split-merge information.
Source codeTlbTransSplitPrepare
@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 codeTlbTransSplitInstall
struct (0b0101) TlbTransSplitInstall {
splitInfo: TlbSplitMergeInfo
prepareTransaction: Cell<TlbTransaction>
installed: bool
}Represents split install transaction description.
Source codeTlbTransMergePrepare
struct (0b0110) TlbTransMergePrepare {
splitInfo: TlbSplitMergeInfo
storagePh: TlbTrStoragePhase
aborted: bool
}Represents merge prepare transaction description.
Source codeTlbTransMergeInstall
@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 codeTlbTransactionDescr
type TlbTransactionDescr =
| TlbTransOrd
| TlbTransStorage
| TlbTransTickTock
| TlbTransSplitPrepare
| TlbTransSplitInstall
| TlbTransMergePrepare
| TlbTransMergeInstallUnion type for all transaction descriptions.
Source codeTlbVarUint7
type TlbVarUint7 = intTlbVarUint7.packToBuilder
fun TlbVarUint7.packToBuilder(self, mutate b: builder): voidTlbVarUint7.unpackFromSlice
fun TlbVarUint7.unpackFromSlice(mutate s: slice): TlbVarUint7TlbVarUint3
type TlbVarUint3 = intTlbVarUint3.packToBuilder
fun TlbVarUint3.packToBuilder(self, mutate b: builder): voidTlbVarUint3.unpackFromSlice
fun TlbVarUint3.unpackFromSlice(mutate s: slice): TlbVarUint3TlbStorageUsed
struct TlbStorageUsed {
cells: TlbVarUint7
bits: TlbVarUint7
}Represents storage used information.
Source codeTlbStorageExtraNone
struct (0b000) TlbStorageExtraNoneRepresents storage extra information.
Source codeTlbStorageExtraDict
struct (0b001) TlbStorageExtraDict {
dictHash: uint256
}TlbStorageExtraInfo
type TlbStorageExtraInfo = TlbStorageExtraNone | TlbStorageExtraDictUnion type for storage extra information.
Source codeTlbStorageInfo
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 codeTlbAccountNone
struct (0b0) TlbAccountNoneRepresents account.
Source codeTlbAccountInfo
struct (0b1) TlbAccountInfo {
/// Account address.
addr: address
/// Storage statistics.
storageStat: TlbStorageInfo
/// Account storage.
storage: TlbAccountStorage
}TlbAccount
type TlbAccount = TlbAccountNone | TlbAccountInfoUnion type for account.
Source codeTlbAccountStateUninit
struct (0b00) TlbAccountStateUninitAccount state in TlbAccountStorage (block.tlb AccountState).
TlbAccountStateActive
struct (0b1) TlbAccountStateActive {
stateInit: StateInit
}TlbAccountStateFrozen
struct (0b01) TlbAccountStateFrozen {
stateHash: uint256
}TlbAccountState
type TlbAccountState = TlbAccountStateUninit | TlbAccountStateActive | TlbAccountStateFrozenUnion type for account storage state.
Source codeTlbAccountStorage
struct TlbAccountStorage {
/// Last transaction logical time.
lastTransLt: uint64
/// Account balance.
balance: TlbCurrencyCollection
/// Account state.
state: TlbAccountState
}Represents account storage.
Source codeTlbShardAccount
struct TlbShardAccount {
account: Cell<TlbAccount>
lastTransHash: uint256
lastTransLt: uint64
}Represents a shard account state.
Source codeLast updated on