Skip to content

Latest commit

 

History

History
58 lines (43 loc) · 3.18 KB

transaction-id.md

File metadata and controls

58 lines (43 loc) · 3.18 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

Method Type Description
setNonce(<nonce>) Integer Set the nonce for the child transaction ID
setScheduled(<schedule>) boolean Set the boolean value for a scheduled transaction ID
TransactionId.generate(<accountId>) AccountId Generates 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>) String Converts a string to transaction ID
TransactionId.withValidStart(<accountId>, <validStart>) AccountId, Instant Create 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]