How to Exempt Hedera Accounts from Custom Token Fees | Hedera Hedera Network Services Token Service Mint and configure tokens and accounts. Consensus Service Verifiable timestamps and ordering of events. Smart Contracts Run Solidity smart contracts. HBAR The Hedera network's native cryptocurrency. Insights How It Works Learn about Hedera from end to end. Explorers View live and historical data on Hedera. Dashboards Analyze network activity and metrics. Network Nodes Understand networks and node types. Devs Start Building Get Started Learn core concepts and build the future. Documentation Review the API and build using your favorite language. Developer Resources Integrations Plugins and microservices for Hedera. Fee Estimator Understand and estimate transaction costs. Open Source Hedera is committed to open, transparent code. Learning Center Learn about web3 and blockchain technologies. Grants Grants & accelerators for your project. Bounties Find bugs. Submit a report. Earn rewards. Ecosystem ECOSYSTEM Hedera Ecosystem Applications, developer tools, network explorers, and more. NFT Ecosystem Metrics Analyze on-chain and market NFT ecosystem metrics. CATEGORIES Web3 Applications Connect into the innovative startups decentralizing the web on Hedera. Enterprise Applications Learn about the Fortune 500 companies decentralizing the web on Hedera. Wallets & Custodians Create a Hedera account to manage HBAR, fungible tokens, and NFTs. Network Explorers Hedera mainnet and testnet graphical network explorers. Developer Tooling Third-party APIs, integrations, and plugins to build apps on Hedera. Grants & Accelerators Boost your project with support from the Hedera ecosystem. Partner Program Explore our partners to bring your vision into reality. Hedera Council Over 30 highly diversified organizations govern Hedera. Use Cases Hedera Solutions Asset Tokenization Studio Open source toolkit for tokenizing assets securely. Stablecoin Studio All-in-one toolkit for stablecoin solutions. Hedera Guardian Auditable carbon markets and traceability. Functional Use Cases Data Integrity & AI Reliable, secure, and ethically governed insights. Sustainability Enabling fair carbon markets with trust. Real-World Asset Tokenization Seamless tokenization of real-world assets and digital at scale. Consumer Engagement & Loyalty Mint, distribute, and redeem loyalty rewards. Decentralized Identity Maintain the lifecycle of credentials. Decentralized Logs Scalable, real-time timestamped events. DeFi Dapps built for the next-generation of finance. NFTs Low, fixed fees. Immutable royalties. Payments Scalable, real-time, and affordable crypto-payments. HBAR Overview Learn about Hedera's token, HBAR. Treasury Management Hedera’s report of the HBAR supply. Governance Decentralized Governance Hedera Council See the world's leading organizations that own Hedera. About Meet Hedera's Board of Directors and team. Journey Watch Hedera's journey to build an empowered digital future for all. Transparent Governance Public Policy Hedera's mission is to inform policy and regulation that impact the industry. Meeting Minutes Immutably recorded on Hedera. Roadmap Follow Hedera's roadmap in its journey to build the future. Resources Company What's New Partners Papers Careers Media Blog Technical Press Podcast Community Events Meetups Store Brand Navigation QUICKSTART How to Exempt Hedera Accounts from Custom Token Fees technical Oct 28, 2022 by Francesco Coacci Developer Evangelist The implementation of HIP-573 in mainnet release v0.31 (November 10th, 2022) enables token creators whose tokenomics require custom fees and different collection accounts to exempt fee collectors from paying custom fees when exchanging token units. This example guides you through the following steps: Creating a Helper Function and defining three new accounts (Account 1, 2, 3) Initializing Fractional Fees for each new account and creating a Fungible Token Transferring 10.000 units from the Treasury Account to Account 2 and then from Account 2 to Account 1 Try It Yourself Get a Hedera testnet account Use this Codesandbox to try the following example Fork the sandbox Remember to provide credentials in the .env file Open a new terminal to execute index.js Get the complete code of this example on GitHub 1. Set Up Helper Functions To simplify creating accounts, you need to create a helper function. In this example, the function is called accountCreator, and the parameters you need to specify are an initial balance and a private key. Note that the token association is automatic to further simplify the tutorial, as you can see below. const accountCreator = async (initialBalance, privateKey) => { const createAccount = new AccountCreateTransaction() .setInitialBalance(initialBalance) .setKey(privateKey.publicKey) .setAlias(privateKey.publicKey.toEvmAddress()) .setMaxAutomaticTokenAssociations(10) .freezeWith(client); const createAccountTx = await createAccount.execute(client); const createAccountRx = await createAccountTx.getReceipt(client); return createAccountRx.accountId; } Copy 2. Define Hedera Accounts Now, you can use the helper function to create three different accounts that will be the collectors of the token fees. // STEP 1: Create three accounts using the helper function const accountKey1 = PrivateKey.generateECDSA(); const accountId1 = await accountCreator(50, accountKey1); const accountKey2 = PrivateKey.generateECDSA(); const accountId2 = await accountCreator(50, accountKey2); const accountKey3 = PrivateKey.generateECDSA(); const accountId3 = await accountCreator(50, accountKey3); console.log(`STEP 1 - Three accounts created: \n ${accountId1} \n ${accountId2} \n ${accountId3}\n`); Copy Console Output: 3. Create Fractional Fees and Fungible Token Let’s define three fractional fees for the fungible token we are about to create. During a token transfer, the first account will receive 1% of the amount, the second 2%, and the third 3%. Note that the critical factor of this tutorial is using the setAllCollectorsAreExempt() extension method on fractional fee creation, as you can see below. const fee1 = new CustomFractionalFee() .setFeeCollectorAccountId(accountId1) .setNumerator(1) .setDenominator(100) .setAllCollectorsAreExempt(true); const fee2 = new CustomFractionalFee() .setFeeCollectorAccountId(accountId2) .setNumerator(2) .setDenominator(100) .setAllCollectorsAreExempt(true); const fee3 = new CustomFractionalFee() .setFeeCollectorAccountId(accountId3) .setNumerator(3) .setDenominator(100) .setAllCollectorsAreExempt(true); Copy Now, you can create the fungible token and specify the fees you just defined. Remember to sign the TokenCreateTransaction() using all the accounts (fee collectors included). const createToken = new TokenCreateTransaction() .setTokenName("HIP-573 Token") .setTokenSymbol("H573") .setTokenType(TokenType.FungibleCommon) .setTreasuryAccountId(operatorId) .setAutoRenewAccountId(operatorId) .setAdminKey(operatorKey) .setFreezeKey(operatorKey) .setWipeKey(operatorKey) .setInitialSupply(100000000) // Total supply = 100000000 / 10 ^ 2 .setDecimals(2) .setCustomFees([fee1, fee2, fee3]) .setMaxTransactionFee(new Hbar(40)) .freezeWith(client); const createTokenSigned1 = await createToken.sign(accountKey1); const createTokenSigned2 = await createTokenSigned1.sign(accountKey2); const createTokenSigned3 = await createTokenSigned2.sign(accountKey3); const createTokenTx = await createTokenSigned3.execute(client); const createTokenRx = await createTokenTx.getReceipt(client); const tokenId = createTokenRx.tokenId; console.log(`STEP 2 - Token with custom fees created: ${tokenId}\n`); Copy Console Output: 4. Transfer Tokens between Fee Collectors Before transferring a token from one collection account to another, you first need to transfer some tokens from the treasury account (in this example, the operator) to one of the collection accounts. // STEP 3: Send token from treasury to one account and from one account to another const transferFromTreasuryTx = await new TransferTransaction() .addTokenTransfer(tokenId, operatorId, -10000) .addTokenTransfer(tokenId, accountId2, 10000) .freezeWith(client) .execute(client); const transferFromTreasuryRx = await transferFromTreasuryTx.getReceipt(client); const transferFromTreasuryStatus = transferFromTreasuryRx.status.toString(); console.log(`STEP 3 \nToken transfer from treasury to account 2: ${transferFromTreasuryStatus}`); Copy Now that Account 2 has 10.000 fungible tokens, you can try to transfer the tokens from Account 2 to Account 1. const transferFromAccount2 = await new TransferTransaction() .addTokenTransfer(tokenId, accountId2, -10000) .addTokenTransfer(tokenId, accountId1, 10000) .freezeWith(client) .sign(accountKey2); const transferFromAccount2Tx = await transferFromAccount2.execute(client); const transferFromAccount2Rx = await transferFromAccount2Tx.getReceipt(client); console.log(`Transfer from account 2 to account 1: ${transferFromAccount2Rx.status.toString()}\n`); Copy Console Output: Done! Now you need to check each account balance to verify if they are actually exempt from token fees. // Check collectors account balance (methods will be deprecated soon, use axios and mirror node api) const checkBalance1 = await new AccountBalanceQuery() .setAccountId(accountId1) .execute(client); const balance1 = checkBalance1.tokens._map.get(tokenId.toString()); const checkBalance2 = await new AccountBalanceQuery() .setAccountId(accountId2) .execute(client); const balance2 = checkBalance2.tokens._map.get(tokenId.toString()); const checkBalance3 = await new AccountBalanceQuery() .setAccountId(accountId3) .execute(client); const balance3 = checkBalance3.tokens._map.get(tokenId.toString()); console.log(`Accounts Balance: \nAccount 1: ${balance1} \nAccount 2: ${balance2} \nAccount 3: ${balance3} \n`); Copy Console Output: v0.30 v0.31 As you can see in v0.30, the third collector receives 3% of the 10.000 transferred from the second to the first collector. While in v0.31, fee collectors are exempt from fees. For further questions, don't hesitate to get in touch with us on the Hedera Discord Server. Check out the Code Check out this code example on GitHub Continue Learning Hedera Improvement Proposals Custom Token Fees (Documentation) Share This Back to blog What is gRPC, gRPC-Web, and Proxies? Ed Marquez Pragmatic Blockchain Design Patterns – Integrating Blockchain into Business Processes Michiel Mulders Zero Cost EthereumTransaction on Success: Hedera's New Fee Model for Relay Operators Oliver Thorn Hedera Adopts Chainlink Standard for Cross-Chain Interoperability To Accelerate Ecosystem Adoption Hedera Team Hedera Developer Highlights March 2025 Michiel Mulders Hedera Release Cycle Overview Ed Marquez View All Posts Sign up for the newsletter CONNECT WITH US Transparency Open Source Audits & Standards Sustainability Commitment Carbon Offsets Governance Hedera Council Public Policy Treasury Management Meeting Minutes LLC Agreement Node Requirements Community Events Meetups HBAR Telegram Developer Discord Twitter Community Support FAQ Network Status Developer Discord StackOverflow Brand Brand Guidelines Built on Hedera Logo Hedera Store About Team Partners Journey Roadmap Careers Contact General Inquiry Public Relations © 2018-2025 Hedera Hashgraph, LLC. All trademarks and company names are the property of their respective owners. All rights in the Deutsche Telekom mark are protected by Deutsche Telekom AG. All rights reserved. Hedera uses the third party marks with permission. Terms of Use  |  Privacy Policy