Skip to main content
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
MethodTypeDescription
execute(<client>)ClientSign with the client operator and submit to a Hedera network
execute(<client, timeout>)Client, DurationThe duration of times the client will try to submit the transaction upon the network being busy
executeWithSigner(<signer>)Sign the transaction with a local wallet. This feature is available in the Hedera JavaScript SDK only. >=v2.11.0
<transactionResponse>.transactionIdTransactionIdReturns the transaction ID of the transaction
<transactionResponse>.nodeIdAccountIdReturns the node ID of the node that processed the transaction
<transactionResponse>.transactionHashbyte [ ]Returns the hash of the transaction
<transactionResponse>.setValidateStatus(<validateStatus>)booleanWhether getReceipt() or getRecord() will throw an exception if the receipt status is not SUCCESS
<transactionResponse>.getValidateStatusbooleanReturn whether getReceipt() or getRecord() will throw an exception if the receipt status is not SUCCESS
The example below uses setKeyWithAlias() to set the EVM Address from Public Key at account creation, the recommended pattern for EVM compatibility. See Create an Account for details, including the immutability behavior and when to use setKeyWithoutAlias() instead.
//Create the transaction
AccountCreateTransaction transaction = new AccountCreateTransaction()
        // Sets the EVM Address from Public Key (recommended for EVM compatibility)
        .setKeyWithAlias(ecdsaPublicKey)
        // Use setKeyWithoutAlias(ecdsaPublicKey) if you plan to rotate keys soon after creation
        .setInitialBalance(new Hbar(1));

//Sign with client operator private key and submit the transaction to a Hedera network
TransactionResponse txResponse = transaction.execute(client);

//Get the transaction ID
TransactionId transactionId = txResponse.transactionId;

//Get the account ID of the node that processed the transaction
AccountId nodeId = txResponse.nodeId;

//Get the transaction hash
byte [] transactionHash = txResponse.transactionHash;

System.out.println("The transaction ID is " +transactionId);
System.out.println("The transaction hash is " +transactionHash);
System.out.println("The node ID is " +nodeId);

//v2.0.0