Hedera
Search…
Freeze an account
Freezes transfers of the specified token for the account. The transaction must be signed by the token's Freeze Key.
  • If the provided account is not found, the transaction will resolve to INVALID_ACCOUNT_ID. If the provided account has been deleted, the transaction will resolve to ACCOUNT_DELETED.
  • If the provided token is not found, the transaction will resolve to INVALID_TOKEN_ID.
  • If the provided token has been deleted, the transaction will resolve to TOKEN_WAS_DELETED.
  • If an Association between the provided token and account is not found, the transaction will resolve to TOKEN_NOT_ASSOCIATED_TO_ACCOUNT.
  • If no Freeze Key is defined, the transaction will resolve to TOKEN_HAS_NO_FREEZE_KEY.
  • Once executed the Account is marked as Frozen and will not be able to receive or send tokens unless unfrozen.
  • The operation is idempotent
Transaction Signing Requirements
  • Freeze key
  • Transaction fee payer account key
Transaction Fees
  • Please see the transaction and query fees table for base transaction fee
  • Please use the Hedera fee estimator to estimate your transaction fee cost
Constructor
Description
new TokenFreezeTransaction()
Initializes the TokenFreezeTransaction object
1
new TokenFreezeTransaction()
Copied!

Methods

V2
V1
​
Method
Type
Description
Requirement
setTokenId(<tokenId>)
TokenId
The token for this account to be frozen
Required
setAccountId(<accountId>)
AccountId
The account to be frozen
Required
Java
1
//Freeze an account from transferring a token
2
TokenFreezeTransaction transaction = new TokenFreezeTransaction()
3
.setAccountId(accountId)
4
.setTokenId(tokenId);
5
​
6
//Freeze the unsigned transaction, sign with the sender freeze private key of the token, submit the transaction to a Hedera network
7
TransactionResponse txResponse = transaction.freezeWith(client).sign(freezeKey).execute(client);
8
9
//Request the receipt of the transaction
10
TransactionReceipt receipt = txResponse.getReceipt(client);
11
12
//Obtain the transaction consensus status
13
Status transactionStatus = receipt.status;
14
15
System.out.print("The transaction consensus status is " +transactionStatus);
16
//v2.0.1
Copied!
JavaScript
1
//Freeze an account from transferring a token
2
const transaction = await new TokenFreezeTransaction()
3
.setAccountId(accountId)
4
.setTokenId(tokenId)
5
.freezeWith(client);
6
​
7
//Sign with the freeze key of the token
8
const signTx = await transaction.sign(freezeKey);
9
​
10
//Submit the transaction to a Hedera network
11
const txResponse = await signTx.execute(client);
12
​
13
//Request the receipt of the transaction
14
const receipt = await txResponse.getReceipt(client);
15
16
//Get the transaction consensus status
17
const transactionStatus = receipt.status;
18
​
19
console.log("The transaction consensus status " +transactionStatus.toString());
20
​
21
//v2.0.7
Copied!
Go
1
//Freeze an account from transferring a token
2
transaction, err = hedera.NewTokenFreezeTransaction().
3
SetAccountID(accountId).
4
SetTokenID(tokenId).
5
FreezeWith(client)
6
​
7
if err != nil {
8
panic(err)
9
}
10
​
11
//Sign with the freeze private key of the token, submit the transaction to a Hedera network
12
txResponse, err := transaction.Sign(freezeKey).Execute(client)
13
14
if err != nil {
15
panic(err)
16
}
17
​
18
//Get the receipt of the transaction
19
receipt, err = txResponse.GetReceipt(client)
20
​
21
if err != nil {
22
panic(err)
23
}
24
25
//Get the transaction consensus status
26
status := receipt.Status
27
​
28
fmt.Printf("The transaction consensus status is %v\n", status)
29
​
30
//v2.1.0
Copied!
Method
Type
Description
Requirement
setTokenId(<tokenId>)
TokenId
The token for this account to be frozen
Required
setAccountId(<accountId>)
AccountId
The account to be frozen
Required
Java
1
//Freeze an account from transferring a token
2
TokenFreezeTransaction transaction = new TokenFreezeTransaction()
3
.setAccountId(newAccountId)
4
.setTokenId(newTokenId);
5
​
6
//Build the unsigned transaction, sign with the sender freeze private key of the token, submit the transaction to a Hedera network
7
TransactionId transactionId = transaction.build(client).sign(freezeKey).execute(client);
8
9
//Request the receipt of the transaction
10
TransactionReceipt getReceipt = transactionId.getReceipt(client);
11
12
//Obtain the transaction consensus status
13
Status transactionStatus = getReceipt.status;
14
15
System.out.print("The transaction consensus status is " +transactionStatus);
16
//Version: 1.2.2
Copied!
JavaScript
1
//Freeze an account from transferring a token
2
const transaction = new TokenFreezeTransaction()
3
.setAccountId(newAccountId)
4
.setTokenId(newTokenId);
5
​
6
//Build the unsigned transaction, sign with the freeze private key of the token, submit the transaction to a Hedera network
7
const transactionId = await transaction.build(client).sign(freezeKey).execute(client);
8
9
//Request the receipt of the transaction
10
const getReceipt = await transactionId.getReceipt(client);
11
12
//Obtain the transaction consensus status
13
const transactionStatus = getReceipt.status;
14
15
console.log("The transaction consensus status is " +transactionStatus);
16
//Version 1.4.2
Copied!
​
Copy link
Contents
Methods