Create a token

Check out the "Getting Started with the Hedera Token Service" video tutorial in JavaScript here.

Create a new fungible or non-fungible token (NFT) on the Hedera network. After you submit the transaction to the Hedera network, you can obtain the new token ID by requesting the receipt.

You can also create, access, or transfer HTS tokens using smart contracts - see Hedera Service Solidity Libraries and Supported ERC Token Standards.

Token Keys

NFTs

For non-fungible tokens, the token ID represents an NFT class. Once the token is created, you must mint each NFT using the token mint operation.

Token Properties

Token Properties

Transaction Signing Requirements

  • Treasury key is required to sign

  • Admin key, if specified

  • Transaction fee payer key

Transaction Fees

  • For fungible tokens, a CryptoTransfer fee is added to transfer the newly created token to the treasury account

  • Please see the transaction and query fees table for the base transaction fee

  • Please use the Hedera fee estimator to estimate your transaction fee cost

Methods

Method
Type
Requirement

setTokenName(<name>)

String

Required

setTokenType(<tokenType>)

Optional

setTokenSymbol(<symbol>)

String

Required

setDecimals(<decimal>)

int

Optional

setInitialSupply(<initialSupply>)

int

Optional

setTreasuryAccountId(<treasury>)

AccountId

Required

setAdminKey(<key>)

Key

Optional

setKycKey(<key>)

Key

Optional

setFreezeKey(<key>)

Key

Optional

setWipeKey(<key>)

Key

Optional

setSupplyKey(<key>)

Key

Optional

setPauseKey(<key>)

Key

Optional

setFreezeDefault(<freeze>)

boolean

Optional

setExpirationTime(<expirationTime>)

Instant

Optional

setFeeScheduleKey(<key>)

Key

Optional

setCustomFees(<customFees>)

Optional

setSupplyType(<supplyType>)

TokenSupplyType

Optional

setMaxSupply(<maxSupply>)

long

Optional

setTokenMemo(<memo>)

String

Optional

setAutoRenewAccountId(<account>)

Optional

setAutoRenewPeriod(<period>)

Duration

Optional

setMetadataKey(<key>)

Key

Optional

setMetadata(<bytes>)

bytes

Optional

Note: Where the Admin, Pause, Freeze, and Wipe keys are left blank, the Supply key will be required as a minimum.

//Create the transaction
TokenCreateTransaction transaction = new TokenCreateTransaction()
        .setTokenName("Your Token Name")
        .setTokenSymbol("F")
        .setTreasuryAccountId(treasuryAccountId)
        .setInitialSupply(5000)
        .setAdminKey(adminKey.getPublicKey())
        .setMetadataKey(metadataKey)
        .setMetadata(metadata)
        .setMaxTransactionFee(new Hbar(30)); //Change the default max transaction fee

//Build the unsigned transaction, sign with admin private key of the token, sign with the token treasury private key, submit the transaction to a Hedera network
TransactionResponse txResponse = transaction.freezeWith(client).sign(adminKey).sign(treasuryKey).execute(client);

//Request the receipt of the transaction
TransactionReceipt receipt = txResponse.getReceipt(client);

//Get the token ID from the receipt
TokenId tokenId = receipt.tokenId;

System.out.println("The new token ID is " + tokenId);

//v2.0.1

Last updated

Was this helpful?