Hedera
Search…
Submit a transaction
The execute() method submits a transaction to a Hedera network. This method will create the transaction ID from the client operator account ID, sign with the client operator private key, and pick a node from the defined network on the client to submit the transaction to. The transaction is also automatically signed with the client operator account private key. You do not need to manually sign transactions if this key is the required key on any given transaction. Once you submit the transaction, the response will include the following:
    The transaction ID of the transaction
    The node ID of the node the transaction was submitted to
    The transaction hash
Transaction Signing Requirements
    Please refer to the specific transaction type and defined key structure of the account, topic, token, file or smart contract to understand the signing requirements
V2
V1
Method
Type
Description
execute(<client>)
Client
Sign with the client operator and submit to a Hedera network
execute(<client, timeout>)
Client, Duration
The duration of times the client will try to submit the transaction upon the network being busy
<transactionResponse>.transactionId
TransactionId
Returns the transaction ID of the transaction
<transactionResponse>.nodeId
AccountId
Returns the node ID of the node that processed the transaction
<transactionResponse>.transactionHash
byte [ ]
Returns the hash of the transaction
Java
1
//Create the transaction
2
AccountCreateTransaction transaction = new AccountCreateTransaction()
3
.setKey(newPublicKey)
4
.setInitialBalance(new Hbar(1000));
5
6
//Sign with client operator private key and submit the transaction to a Hedera network
7
TransactionResponse txResponse = transaction.execute(client);
8
9
//Get the transaction ID
10
TransactionId transactionId = txResponse.transactionId;
11
12
//Get the account ID of the node that processed the transaction
13
AccountId nodeId = txResponse.nodeId;
14
15
//Get the transaction hash
16
byte [] transactionHash = txResponse.transactionHash;
17
18
System.out.println("The transaction ID is " +transactionId);
19
System.out.println("The transaction hash is " +transactionHash);
20
System.out.println("The node ID is " +nodeId);
21
22
//v2.0.0
Copied!
JavaScript
1
//Create the transaction
2
const transaction = new AccountCreateTransaction()
3
.setKey(newPublicKey)
4
.setInitialBalance(new Hbar(1000));
5
6
//Sign with client operator private key and submit the transaction to a Hedera network
7
const txResponse = await transaction.execute(client);
8
9
//Get the transaction ID
10
const transactionId = txResponse.transactionId;
11
12
//Get the account ID of the node that processed the transaction
13
const nodeId = txResponse.nodeId;
14
15
//Get the transaction hash
16
const transactionHash = txResponse.transactionHash;
17
18
console.log("The transaction ID is " +transactionId);
19
console.log("The transaction hash is " +transactionHash);
20
console.log("The node ID is " +nodeId);
21
22
//v2.0.0
Copied!
Go
1
//Create the transaction
2
transaction := hedera.NewAccountCreateTransaction().
3
SetKey(publicKey).
4
SetInitialBalance(hedera.NewHbar(1000))
5
6
//Sign with client operator private key and submit the transaction to a Hedera network
7
txResponse, err := transaction.Execute(client)
8
9
if err != nil {
10
panic(err)
11
}
12
13
//Get the transaction ID
14
transactionId := txResponse.TransactionID
15
16
//Get the account ID of the node that processed the transaction
17
transactionNodeId := txResponse.NodeID
18
19
//Get the transaction hash
20
transactionHash := txResponse.Hash
21
22
fmt.Printf("The transaction id is %v\n", transactionId)
23
fmt.Printf("The transaction hash is %v\n", transactionHash)
24
fmt.Printf("The node id is %v\n", transactionNodeId)
25
26
//v2.0.0
Copied!
Method
Type
Description
Java
1
Copied!
JavaScript
1
Copied!
Last modified 6d ago
Copy link