Hedera
Search…
Modify transaction fields
For every transaction submitted to a Hedera network you can modify the transaction ID, amount of time the transaction has to reach consensus, a memo field to attach a note, the account ID of the node the transaction will be submitted to, and the maximum fee the client is willing to pay for a given transaction. The SDKs do not require you to set these fields when submitting a transaction to a Hedera network as the SDK either creates the value at the time of submission or inputs default values. The methods listed below can be used to modify any of these values.
Note: The total size for a given transaction is limited to 6KiB
Fields
Description
Transaction ID
Set the ID for this transaction. The transaction ID includes the operator's account ( the account paying the transaction fee). If two transactions have the same transaction ID, they won't both have an effect. One will complete normally and the other will fail with a duplicate transaction status.
Normally, you should not use this method. Just before a transaction is executed, a transaction ID will be generated from the operator on the client.
Valid Duration
Set the duration that this transaction is valid for
Note: Max network valid duration is 180 seconds. SDK default value is 120 seconds
Memo
Set a note or description that should be recorded in the transaction record (maximum length of 100 characters). Anyone can view this memo on the network
Node ID
Set the account ID of the node that this transaction will be submitted to.
Max transaction fee
Set the max transaction fee for the operator (transaction fee payer account) is willing to pay
Default: 1 hbar
V2
V1
Method
Type
Requirement
setTransactionID(<transactionId>)
TransactionID
Optional
setTransactionValidDuration(<validDuration>)
Duration
Optional
setTransactionMemo(<memo>)
String
Optional
setNodeAccountIds(<nodeAccountIds>)
List<AccountId>
Optional
setMaxTransactionFee(<maxTransactionFee>)
Hbar
Optional
Java
1
//Create the transaction and set the transaction properties
2
Transaction transaction = new AccountCreateTransaction() //Any transaction can be applied here
3
.setKey(key)
4
.setInitialBalance(Hbar.fromTinybars(1000))
5
.setMaxTransactionFee(new Hbar(2)) //Set the max transaction fee to 2 hbar
6
.setTransactionMemo("Transaction memo"); //Set the node ID to submit the transaction to
7
8
//v2.0.0
Copied!
JavaScript
1
//Create the transaction and set the transaction properties
2
const transaction = await new AccountCreateTransaction() //Any transaction can be applied here
3
.setKey(key)
4
.setInitialBalance(Hbar.fromTinybars(1000))
5
.setMaxTransactionFee(new Hbar(2)) //Set the max transaction fee to 2 hbar
6
.setTransactionMemo("Transaction memo"); //Set the node ID to submit the transaction to
Copied!
Go
1
//Create the transaction and set the transaction properties
2
transaction := hedera.NewAccountCreateTransaction(). //Any transaction can be applied here
3
SetKey(newKey.PublicKey()).
4
SetInitialBalance(hedera.NewHbar(1000)).
5
SetMaxTransactionFee(hedera.NewHbar(2)). //Set the max transaction fee to 2 hbar
6
SetTransactionMemo("Transaction memo") //Set the transaction memo
7
8
//v2.0.0
Copied!
Method
Type
Requirement
setTransactionID(<transactionId>)
TransactionID
Optional
setTransactionValidDuration(<validDuration>)
Duration
Optional
setTransactionMemo(<memo>)
String
Optional
setNodeAccountId(<nodeAccountId>)
AccountId
Optional
setMaxTransactionFee(<maxTransactionFee>)
long/Hbar
Optional
Java
1
//Create the transaction and set the transaction properties
2
Transaction transaction = new AccountCreateTransaction() //Any transaction can be applied here
3
.setKey(publicKey)
4
.setInitialBalance(new Hbar(100))
5
.setMaxTransactionFee(new Hbar(2)) //Set the max transaction fee to 2 hbar
6
.setTransactionMemo("Transaction memo"); //Set the node ID to submit the transaction to
7
8
//v1.3.2
Copied!
JavaScript
1
//Create the transaction and set the transaction properties
2
const transaction = new AccountCreateTransaction() //Any transaction can be applied here
3
.setKey(publicKey)
4
.setInitialBalance(new Hbar(100))
5
.setMaxTransactionFee(new Hbar(2)) //Set the max transaction fee to 2 hbar
6
.setTransactionMemo("Transaction memo");
7
8
//v1.4.4
Copied!

Get transaction properties

V2
Method
Type
Requirement
getTransactionID()
TransactionID
Optional
getTransactionValidDuration()
Duration
Optional
getTransactionMemo()
String
Optional
getNodeAccountId()
AccountID
Optional
getMaxTransactionFee()
Hbar
Optional
getTransactionHash()
byte[ ]
Optional
getTransactionHashPerNode()
Map<AccountId, byte [ ]>
Optional
getSignatures()
Map<AccountId, Map<PublicKey, byte [ ]>>
Optional
Java
1
//Create the transaction and set the transaction properties
2
Transaction transaction = new AccountCreateTransaction() //Any transaction can be applied here
3
.setInitialBalance(Hbar.fromTinybars(1000))
4
.setMaxTransactionFee(new Hbar(100)) //Set the max transaction fee to 100 hbar
5
.setNodeAccountId(new AccountId(3)) //Set the node ID to submit the transaction to
6
.setTransactionMemo("Transaction memo"); //Add a transaction memo
7
8
Hbar maxTransactionFee = transaction.getMaxTransactionFee();
9
//v2.0.0
Copied!
JavaScript
1
//Create the transaction and set the transaction properties
2
const transaction = await new AccountCreateTransaction() //Any transaction can be applied here
3
.setInitialBalance(Hbar.fromTinybars(1000))
4
.setMaxTransactionFee(new Hbar(100)) //Set the max transaction fee to 100 hbar
5
.setNodeAccountId(new AccountId(3)) //Set the node ID to submit the transaction to
6
.setTransactionMemo("Transaction memo"); //Add a transaction memo
7
8
const maxTransactionFee = transaction.getMaxTransactionFee();
Copied!
Go
1
//Create the transaction and set the transaction properties
2
transaction := hedera.NewAccountCreateTransaction(). //Any transaction can be applied here
3
SetKey(newKey.PublicKey()).
4
SetInitialBalance(hedera.NewHbar(1000)).
5
SetMaxTransactionFee(hedera.NewHbar(2)). //Set the max transaction fee to 2 hbar
6
SetTransactionMemo("Transaction memo") //Add a transaction memo
7
8
maxtransactionFee := transaction.GetMaxTransactionFee()
9
//v2.0.0
Copied!

Last modified 6d ago