blog

Developer Quick-Start: Custom Token Fees

September 2, 2021
Hedera Team
Hedera
Hedera provides secure, scalable infrastructure for real-world decentralized applications in finance, AI, and sustainability, governed by global enterprises.

The Hedera mainnet was upgraded to v0.17.4 on September 2nd, 2021. It included the new functionality of HIP-18: Custom Hedera Token Service Fees — the ability for anyone issuing a token on Hedera using the Hedera Token Service to include programmatic custom fees.

Custom fees can be `fractional`, `fixed`, or `royalty`:

  • Fixed Fee: A fixed fee transfers a set number of tokens, collected as a fee, every time a token transfer is initiated.

  • Fractional Fee: A fractional fee transfers a variable number of tokens, collected as a fee, every time a token transfer is initiated. The amount is configured by setting a numerator and denominator to determine a fractional (or percentage) fee. Fractional fees can be configured to impose minimum and maximum limits on the amount transferred.

  • Royalty Fee: A royalty fee can be enabled on the fee schedule of an NFT and collected during the transfer of ownership. This fee is defined as a fraction of the fungible token value used in exchange (HBAR or a custom fungible token) for the NFT, as defined by the fee schedule of the NFT. The fee is collected from the receiver of the NFT in a transaction and sent to the NFT’s fee collector account, as defined in the fee schedule.

Fees are configured to be paid in the token being transacted, any other type of token created using Hedera Token Service, or hbar.

In this blog posting, we’re going to outline specific application use cases for custom token fees and code examples to help you get started. The official Hedera SDKs in Java, Javascript, and Go all support custom token fees; you can read the full documentation here.

Custom Token Fee Use Cases and Code Examples

Here are some JavaScript examples (below) of how you can use the new custom fee features. The features we will go over are creating the fee schedules either with CustomeFractionalFee(), or CustomFixedFee(), or CustomRoyaltyFee() and then the inclusion of these fee schedules in the TokenCreateTransaction().

Custom Fractional Fee Schedule

The new fractional fee schedule is represented by the CustomFractionalFee() object. The object has a numerator attribute, a denominator attribute, and a collector account attribute. The numerator and denominator attributes make up the fraction for the fractional fee. The below snippet is an example of how to make a fractional fee schedule of 10% in JavaScript.

Custom Fixed Fee Schedule

The new fixed fee schedule is represented by the CustomFixedFee() object. The object has a

denominating token attribute, an amount attribute, and also collector account attribute. The denominating token attribute takes a tokenID and if left empty will default to hbar. The below snippet is an example of how to make a fixed fee schedule of 5 hbars in JavaScript.

Including your fee schedule in a new token

Now that we have gone over how to create the new fee schedules, we will give an example of how to include them in your new token when using the TokenCreateTransaction object. All you have to do is include the .setCustomFees() passing in the fee schedule you have recently created. The below code snippet is an example of how to set the fee schedule to the fractional fee defined above for 10%.

The TokenCreateTransaction() can take up to 10 custom fee schedules.

Details & Limitations

  • A fungible token’s fee schedule can include a combination of both fractional and fixed fees.

  • Negative fixed or fractional fee values are not allowed.

  • The token’s treasury account and fee collector account(s) are exempt from paying fees to transfer said token.

  • If the sender or receiver account configured does not have enough tokens to pay the fee(s) (plus the amount being transferred), the transaction will fail.
    • A single transfer transaction cannot alter more than 20 account balances. A debit of tokens from one account and credit to another is equal to 2 account balance alterations.

  • Only two ‘layers’ of custom HTS fees are allowed.
    • In other words, a token being transferred may have a custom fee schedule (first layer) which requires you to pay fees in another token that has its own fee schedule (second layer). If that’s the case, a token paid as a fee within the second layer cannot have its own fee schedule — otherwise, that would create a third layer.

For more information visit the official Hedera documentation or reach out to me at @HogwoodWaylon if you have any specific questions on how to utilize the custom fee features in the SDK.

Updates

With the upcoming mainnet upgrade to v0.31 (November 10th, 2022) and the introduction of HIP-573, a token creator can exempt all fee collectors from paying custom fees when exchanging token units. Check out this article if you want to learn more.

Back to Blog

discover

See more articles

February 2, 2026

Announcing Support of Swift 6 in the Hiero Swift SDK

The Hiero Swift SDK will be officially supporting Swift 6.0, 6.1, and 6.2 as of version v0.47.0 released February 2nd. This change is an investment in safety, performance, and long-term
Read More
January 30, 2026

Hedera Developer Highlights January 2026

First of, Hedera DevDay is coming to Denver on February 17, 2026, alongside ETHDenver, bringing a full day dedicated to building on Hedera with deep technical sessions, ecosystem updates, and
Read More
January 26, 2026

Hedera at Davos 2026: Advancing digital trust 

Hedera returned to the World Economic Forum’s Annual Meeting in Davos, 2026, engaging policymakers, enterprise leaders, and innovators in forward-looking conversations.
Read More