Skip to content

Latest commit

 

History

History
51 lines (36 loc) · 2.93 KB

transaction-id.md

File metadata and controls

51 lines (36 loc) · 2.93 KB

Transaction ID

A transaction ID is composed of the payer account ID and the timestamp in seconds.nanoseconds format ([email protected]). You are not required to generate a transaction ID for every transaction type as the SDKs generate them when submitting transactions.

Schedule Transaction ID

Scheduled transactions have a schedule flag in the transaction ID ([email protected]?schedule).

Child Transaction ID

Child transactions are transactions that were triggered by a parent transaction. Child transactions have a nonce populated in the transaction ID after the timestamp. The nonce value for the parent transaction ID is 0. The transaction ID (payer and timestamp) is the same as the parent transaction for each child transaction. Each child transaction adds a nonce value to the parent transaction ID. For example, a parent transaction with one child transaction would result in the child transaction having a nonce value of 1 ([email protected]/1). The parent transaction ID for the child transaction would be [email protected].

Constructor Description
new TransactionId() Initializes the TransactionId object

Generate a transaction ID

MethodTypeDescription
setNonce(<nonce>)IntegerSet the nonce for the child transaction ID
setScheduled(<schedule>)booleanSet the boolean value for a scheduled transaction ID
TransactionId.generate(<accountId>)AccountIdGenerates a new transaction ID. Pass the payer account ID to generate the transaction ID.
TransactionId.fromBytes(<bytes>)byte [ ]Converts to a transaction ID from bytes
TransactionId.fromString(<string>)StringConverts a string to transaction ID
TransactionId.withValidStart(<accountId>, <validStart>)AccountId, InstantCreate a transaction ID by passing the payer account and valid start time

{% tabs %} {% tab title="Java" %}

TransactionId txId = TransactionId.generate(new AccountId(5));
System.out.println(txId);

//v2.0.0

{% endtab %}

{% tab title="JavaScript" %}

const txId = TransactionId.generate(new AccountId(5));
console.log(txId);
//v2.0.0

{% endtab %}

{% tab title="Go" %}

txId := hedera.TransactionIDGenerate(client.GetOperatorAccountID())
fmt.println(txId)

//v2.0.0

{% endtab %} {% endtabs %}

Sample Output:

[email protected]