Hedera
Search…
Mint a token
Minting fungible token allows you to increase the total supply of the token. Minting a non-fungible token creates an NFT with its unique metadata for the class of NFTs defined by the token ID. The Supply Key must sign the transaction.
  • If no Supply Key is defined, the transaction will resolve to TOKEN_HAS_NO_SUPPLY_KEY. The maximum total supply a token can have is 2^63-1.
  • The amount provided must be in the lowest denomination possible.
    • Example: Token A has 2 decimals. In order to mint 100 tokens, one must provide an amount of 10000. In order to mint 100.55 tokens, one must provide an amount of 10055.
  • The metadata field is specific to NFTs. Once an NFT is minted, the metadata cannot be changed and is immutable.
    • You can use the metadata field to add a URI that contains additional information about the token. You can view the metadata schema here. The metadata field has a 100 character limit.
  • The serial number for the NFT is returned in the receipt of the transaction.
  • When minting NFTs, do not set the amount. The amount is used for minting fungible tokens only.
Transaction Signing Requirements
  • Supply 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 TokenMintTransaction()
Initializes a TokenMintTransaction object
1
new TokenMintTransaction()
Copied!

Methods

V2
V1
Method
Type
Description
Requirement
setTokenId(<tokenId>)
TokenId
The token ID for which to mint additional tokens
Required
setAmount(<amount>)
long
Applicable to tokens of type FUNGIBLE_COMMON.The amount to mint to the Treasury Account. The amount must be a positive non-zero number represented in the lowest denomination of the token. The new supply must be lower than 2^63-1.
Optional
setMetadata(<metaDatas>)
List<byte[]>
Applicable to tokens of type NON_FUNGIBLE_UNIQUE. A list of metadata that are being created. The maximum allowed size of each metadata is 100 bytes and is immutable.
Optional
addMetadata(<metaData>)
byte []
Applicable to tokens of type NON_FUNGIBLE_UNIQUE. A list of metadata that are being created. The maximum allowed size of each metadata is 100 bytes and is immutable.
Optional
Java
1
//Mint another 1,000 tokens
2
TokenMintTransaction transaction = new TokenMintTransaction()
3
.setTokenId(tokenId)
4
.setAmount(1000);
5
​
6
//Freeze the unsigned transaction, sign with the supply private key of the token, submit the transaction to a Hedera network
7
TransactionResponse txResponse = transaction.freezeWith(client).sign(supplyKey).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.println("The transaction consensus status is " +transactionStatus;
16
​
17
//v2.0.1
Copied!
JavaScript
1
//Mint another 1,000 tokens and freeze the unsigned transaction for manual signing
2
const transaction = await new TokenMintTransaction()
3
.setTokenId(tokenId)
4
.setAmount(1000)
5
.freezeWith(client);
6
​
7
//Sign with the supply private key of the token
8
const signTx = await transaction.sign(supplyKey);
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
//Mint another 1,000 tokens and freeze the unsigned transaction for manual signing
2
transaction, err = hedera.NewTokenMintTransaction().
3
SetTokenID(tokenId).
4
SetAmount(1000).
5
FreezeWith(client)
6
​
7
if err != nil {
8
panic(err)
9
}
10
​
11
//Sign with the supply private key of the token, submit the transaction to a Hedera network
12
txResponse, err := transaction.Sign(supplyKey).Execute(client)
13
​
14
if err != nil {
15
panic(err)
16
}
17
​
18
//Request 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 which to mint tokens
Required
setAmount(<amount>)
long
The amount to mint to the Treasury Account. Amount must be a positive non-zero number represented in the lowest denomination of the token. The new supply must be lower than 2^63.
Required
addMetadata(<metadata>)
byte[]
Applicable to tokens of type NON_FUNGIBLE_UNIQUE. A list of metadata that are being created. The maximum allowed size of each metadata is 100 bytes.
Optional
addMetadata(<metadatas>)
List<byte[]>
Applicable to tokens of type NON_FUNGIBLE_UNIQUE. A list of metadata that are being created.The maximum allowed size of each metadata is 100 bytes.
Optional
addMetadata(<metadatas>)
String
Applicable to tokens of type NON_FUNGIBLE_UNIQUE. A list of metadata that are being created. The maximum allowed size of each metadata is 100 bytes.
Optional
Java
1
//Mint another 1,000 tokens
2
TokenMintTransaction transaction = new TokenMintTransaction()
3
.setTokenId(newTokenId)
4
.setAmount(1000);
5
​
6
//Build the unsigned transaction, sign with the supply private key of the token, submit the transaction to a Hedera network
7
TransactionId transactionId = transaction.build(client).sign(supplyKey).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.println("The transaction consensus status is " +transactionStatus);
16
//Version: 1.2.2
Copied!
JavaScript
1
//Mint another 1,000 tokens
2
const transaction = new TokenMintTransaction()
3
.setTokenId(newTokenId)
4
.setAmount(1000);
5
​
6
//Build the unsigned transaction, sign with supply private key of the token, submit the transaction to a Hedera network
7
const transactionId = await transaction.build(client).sign(supplyKey).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