A transaction that updates the properties of an existing account. The network will store the latest updates on the account. If you would like to retrieve the state of an account in the past, you can query a mirror node.
The account key(s) are required to sign the transaction
If you are updating the keys on the account the OLD KEY and NEW KEY must sign
If either is a key list then the key list keys are all required to sign
If either is a threshold key, the threshold value is required to sign
If you do not have the required signatures, the network will throw an INVALID_SIGNATURE error
Methods
Method
Type
Requirement
setAccountId(<accountId>)
AccountId
Required
setKey(<key>)
Key
Optional
setReceiverSignatureRequired(<boolean>)
Boolean
Optional
setMaxAutomaticTokenAssociations(<amount>)
int
Optional
setAccountMemo(<memo>)
String
Optional
setAutoRenewPeriod(<duration>)
Duration
Optional
setStakedAccountId(<stakedAccountId>)
AccountId
Optional
setStakedNodeId(<stakedNodeId>)
long
Optional
setDeclineStakingReward(<declineStakingReward>)
boolean
Optional
setExpirationTime(<expirationTime>)
Instant
Disabled
//Create the transaction to update the key on the accountAccountUpdateTransaction transaction =newAccountUpdateTransaction().setAccountId(accountId).setKey(updateKey);//Sign the transaction with the old key and new key, submit to a Hedera network TransactionResponse txResponse =transaction.freezeWith(client).sign(oldKey).sign(newKey).execute(client);//Request the receipt of the transactionTransactionReceipt receipt =txResponse.getReceipt(client);//Get the transaction consensus statusStatus transactionStatus =receipt.status;System.out.println("The transaction consensus status is "+transactionStatus);//Version 2.0.0
//Create the transaction to update the key on the accountconsttransaction=awaitnewAccountUpdateTransaction().setAccountId(accountId).setKey(updateKey).freezeWith(client);//Sign the transaction with the old key and new keyconstsignTx=await (awaittransaction.sign(oldKey)).sign(newKey);//SIgn the transaction with the client operator private key and submit to a Hedera networkconsttxResponse=awaitsignTx.execute(client);//Request the receipt of the transactionconstreceipt=awaittxResponse.getReceipt(client);//Get the transaction consensus statusconsttransactionStatus=receipt.status;console.log("The transaction consensus status is "+transactionStatus.toString());//v2.0.5
//Create the transaction to update the key on the accounttransaction, err := hedera.NewAccountUpdateTransaction().SetAccountID(newAccountId).SetKey(updateKey.PublicKey()).FreezeWith(client)if err !=nil {panic(err)}//Sign the transaction with the old key and new key, submit to a Hedera network txResponse, err := transaction.Sign(newKey).Sign(updateKey).Execute(client)//Request the receipt of the transactionreceipt, err := txResponse.GetReceipt(client)if err !=nil {panic(err)}//Get the transaction consensus statustransactionStatus := receipt.Statusprintln("The transaction consensus status is ", transactionStatus)//Version 2.0.0
Get transaction values
Return the properties of an account create transaction.
Method
Type
Description
getKey()
Key
Returns the public key on the account
getInitialBalance()
Hbar
Returns the initial balance of the account
getReceiverSignatureRequired()
boolean
Returns whether the receiver signature is required or not
getExpirationTime()
Instant
Returns the expiration time
getAccountMemo()
String
Returns the account memo
getDeclineStakingReward()
boolean
Returns whether or not the account is declining rewards
getStakedNodeId()
long
Returns the node ID the account is staked to
getStakedAccountId()
AccountId
Returns the account ID the node is staked to
getAutoRenewPeriod()
Duration
Returns the auto renew period on the account
//Create a transactionAccountUpdateTransaction transaction =newAccountUpdateTransaction().setAccountId(accountId).setKey(newKeyUpdate);//Get the key on the accountKey accountKey =transaction.getKey();//v2.0.0
//Create a transactionconsttransaction=newAccountUpdateTransaction().setAccountId(accountId).setKey(newKeyUpdate);//Get the key of an accountconstaccountKey=transaction.getKey();//v2.0.0
//Create the transaction transaction, err :=hedera.NewAccountUpdateTransaction().SetAccountID(newAccountId).SetKey(updateKey.PublicKey())//Get the key of an accountaccountKey :=transaction.GetKey()//v2.0.0