Skip to main content

Class: TransactionHelper

Helper methods for Transactions.

Table of contents

Properties

Methods

Constructors

Properties

CONFIRMED_MILESTONE_INDEX_LENGTH

Static CONFIRMED_MILESTONE_INDEX_LENGTH: number = 4

The confirmed milestone index length.


CONFIRMED_UINIX_TIMESTAMP_LENGTH

Static CONFIRMED_UINIX_TIMESTAMP_LENGTH: number = 4

The confirmed unix timestamp length.


OUTPUT_ID_LENGTH

Static OUTPUT_ID_LENGTH: number = 34

The output Id length.

Methods

calculateBlockId

Static calculateBlockId(block): string

Calculate blockId from a block.

Parameters

NameTypeDescription
blockIBlockThe block.

Returns

string

The blockId.


outputIdFromTransactionData

Static outputIdFromTransactionData(transactionId, outputIndex): string

Returns the outputId from transation id and output index.

Parameters

NameTypeDescription
transactionIdstringThe id of the transaction.
outputIndexnumberThe index of the output.

Returns

string

The output id.


getTransactionEssenceHash

Static getTransactionEssenceHash(essence): Uint8Array

Calculate the Transaction Essence hash.

Parameters

NameTypeDescription
essenceITransactionEssenceThe transaction essence.

Returns

Uint8Array

The transaction essence hash.


getTransactionPayloadHash

Static getTransactionPayloadHash(transactionPayload): Uint8Array

Calculate the Transaction hash.

Parameters

NameTypeDescription
transactionPayloadITransactionPayloadThe payload of the transaction.

Returns

Uint8Array

The transaction hash.


inputFromOutputId

Static inputFromOutputId(outputId): IUTXOInput

Calculate the UTXO input from an output Id.

Parameters

NameTypeDescription
outputIdstringThe id of the output.

Returns

IUTXOInput

The UTXO Input.


getInputsCommitment

Static getInputsCommitment(inputs): string

Calculate the inputCommitment from the output objects that are used as inputs to fund the transaction.

Parameters

NameTypeDescription
inputsOutputTypes[]The output objects used as inputs for the transaction.

Returns

string

The inputs commitment.


getStorageDeposit

Static getStorageDeposit(output, rentStructure): number

Calculates the required storage deposit of an output.

Parameters

NameTypeDescription
outputOutputTypesThe output.
rentStructureIRentRent cost of objects which take node resources.

Returns

number

The required storage deposit.


resolveIdFromOutputId

Static resolveIdFromOutputId(outputId): string

Returns the nftId/aliasId from an outputId. NftId/aliasId is Blake2b-256 hash of the outputId that created it.

Parameters

NameTypeDescription
outputIdstringThe id of the output.

Returns

string

The resolved Nft id or Alias id.


constructTokenId

Static constructTokenId(aliasId, serialNumber, tokenSchemeType): string

Constructs a tokenId from the aliasId, serial number and token scheme type.

Parameters

NameTypeDescription
aliasIdstringThe alias Id of the alias that controls the foundry.
serialNumbernumberThe serial number of the foundry.
tokenSchemeTypenumberThe tokenSchemeType of the foundry.

Returns

string

The tokenId.


networkIdFromNetworkName

Static networkIdFromNetworkName(networkName): string

Calculates the networkId value from the network name.

Parameters

NameTypeDescription
networkNamestringThe name of the network.

Returns

string

The networkId.

Constructors

constructor

new TransactionHelper()