Get Started with the Hedera Token Service - Part 2: KYC,… | 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 Get Started with the Hedera Token Service - Part 2: KYC, Update, and Scheduled Transactions technical Nov 03, 2021 by Ed Marquez Head of Developer Relations In Part 1 of the series, you saw how to mint and transfer an NFT using the Hedera Token Service (HTS). Now, in Part 2, you will see how to take advantage of the flexibility you get when you create and configure your tokens with HTS. More specifically, you will learn how to: Enable and disable a KYC flag for a token (KYC stands for “know your customer”) Update token properties (only possible if it’s a mutable token. Hint: AdminKey) Schedule transactions (like a token transfer) Note: To make sure you have everything you need to follow along, be sure to check out these getting started resources. There, you will see how to create a Hedera testnet account, and then you can configure your development environment. If you want the entire code used, skip to the Code Check section below. Understanding KYC and Hedera Tokens KYC Key When you create a token with HTS, you can optionally use the .setKycKey() method to enable this to grant (or revoke) KYC status of other accounts so they can transact with your token. You would consider using the KYC flag when you need your token to be used only within parties that have been “authorized” to use it. For instance, known registered users, or those who have passed identity verification. Think of this as identity and compliance features like: anti-money laundering (AML) requirements, or any type of off-ledger authentication mechanism, like if a user has signed up for your application. The .setKycKey() method is not required when you create your token, so if you don’t use the method that means anyone who is associated with your token can transact without having to be “authorized”. No KYC key also means that KYC grant or revoke operations are not possible for the token in the future. Enable Token KYC on an Account We will continue with the NFT example from Part 1. However, we have to create a new token using .setKycKey(). Before users can transfer the newly created token, we must grant KYC to those users, namely Alice and Bob. // ENABLE TOKEN KYC FOR ALICE AND BOB let aliceKyc = await kycEnableFcn(aliceId); let bobKyc = await kycEnableFcn(bobId); console.log(`- Enabling token KYC for Alice's account: ${aliceKyc.status}`); console.log(`- Enabling token KYC for Bob's account: ${bobKyc.status}\n`); Copy // KYC ENABLE FUNCTION ========================================== async function kycEnableFcn(id) { let kycEnableTx = await new TokenGrantKycTransaction() .setAccountId(id) .setTokenId(tokenId) .freezeWith(client) .sign(kycKey); let kycSubmitTx = await kycEnableTx.execute(client); let kycRx = await kycSubmitTx.getReceipt(client); return kycRx; } Copy Console output: Disable Token KYC on an Account After the KYC flag has been set to true for a user, the administrator, identity provider, or compliance manager can revoke or disable the KYC flag. After KYC is disabled for a user, he or she can longer receive or send that token. Here’s sample code for disabling token KYC on Alice’s account: // DISABLE TOKEN KYC FOR ALICE let kycDisableTx = await new TokenRevokeKycTransaction() .setAccountId(aliceId) .setTokenId(tokenId) .freezeWith(client) .sign(kycKey); let kycDisableSubmitTx = await kycDisableTx.execute(client); let kycDisableRx = await kycDisableSubmitTx.getReceipt(client); console.log(`- Disabling token KYC for Alice's account: ${kycDisableRx.status} \n`); Copy Console output: Note: The following sections require that Alice has token KYC enabled. Updating tokens If you create a token using the .setAdminKey() method, then you can “update” that token, meaning change its metadata and characteristics. For instance, you can change the token name, symbol, or the keys that are associated with its controlled mutability. You could create a token that initially has a 1 of 1 key for minting and burning, and over time, change this to a threshold or multi-signature key. You can rotate the keys associated with compliance and administration or even remove them entirely, offering a more decentralized approach over time. On the other hand, if you create a token without using .setAdminKey(), then that token is immutable and its properties cannot be modified. In our example, we start by checking the initial KYC key for the token, then we update the KYC key from to , and then we query the token again to make sure the key change took place. // QUERY TO CHECK INITIAL KYC KEY var tokenInfo = await tQueryFcn(); console.log(`- KYC key for the NFT is: \n${tokenInfo.kycKey.toString()} \n`); // UPDATE TOKEN PROPERTIES: NEW KYC KEY let tokenUpdateTx = await new TokenUpdateTransaction() .setTokenId(tokenId) .setKycKey(newKycKey) .freezeWith(client) .sign(adminKey); let tokenUpdateSubmitTx = await tokenUpdateTx.execute(client); let tokenUpdateRx = await tokenUpdateSubmitTx.getReceipt(client); console.log(`- Token update transaction (new KYC key): ${tokenUpdateRx.status} \n`); // QUERY TO CHECK CHANGE IN KYC KEY var tokenInfo = await tQueryFcn(); console.log(`- KYC key for the NFT is: \n${tokenInfo.kycKey.toString()}`); Copy // TOKEN QUERY FUNCTION ========================================== async function tQueryFcn() { var tokenInfo = await new TokenInfoQuery().setTokenId(tokenId).execute(client); return tokenInfo; } Copy Console output: Schedule Transactions Scheduled transactions enable you to collect the required signatures for a transaction in preparation for its execution. This can be useful if you don’t have all the required signatures for the network to immediately process the transaction. Currently you can schedule: TransferTransaction() (for hbar and HTS tokens), TokenMintTransaction(), TokenBurnTransaction(), and TopicMessageSubmitTransaction(). More transactions are supported with new releases. Now, we will schedule a token transfer from Bob to Alice using scheduled transactions. This token transfer requires signatures from both parties. Given that we don’t have Alice’s and Bob’s signatures immediately available (for the purposes of this example), we first create the NFT transfer without signatures. Then, we create the scheduled transaction using the constructor ScheduleCreateTransaction(), and specify the NFT transfer as the transaction to schedule using the .setScheduledTransaction() method. // CREATE THE NFT TRANSFER FROM BOB->ALICE TO BE SCHEDULED // REQUIRES ALICE'S AND BOB'S SIGNATURES let txToSchedule = new TransferTransaction() .addNftTransfer(tokenId, 2, bobId, aliceId) .addHbarTransfer(aliceId, -200) .addHbarTransfer(bobId, 200); // SCHEDULE THE NFT TRANSFER TRANSACTION CREATED IN THE LAST STEP let scheduleTx = await new ScheduleCreateTransaction().setScheduledTransaction(txToSchedule).execute(client); let scheduleRx = await scheduleTx.getReceipt(client); let scheduleId = scheduleRx.scheduleId; let scheduledTxId = scheduleRx.scheduledTransactionId; console.log(`- The schedule ID is: ${scheduleId}`); console.log(`- The scheduled transaction ID is: ${scheduledTxId} \n`); Copy Console output: The token transfer is now scheduled, and it will be executed as soon as all required signatures are submitted. Note that the scheduled transaction IDs (scheduledTxId in this case) have a “scheduled” flag that you can use to confirm the status of the transaction. As of the time of this writing, a schedule transaction has 30 minutes to collect all the required signatures before it can be executed or it expires (deleted from the network). If you set an for the schedule transaction, then you can delete it before its execution or expiration. Now, we submit the required signatures and get schedule information to check the status of our transfer. // SUBMIT ALICE'S SIGNATURE FOR THE TRANSFER TRANSACTION let aliceSignTx = await new ScheduleSignTransaction().setScheduleId(scheduleId).freezeWith(client).sign(aliceKey); let aliceSignSubmit = await aliceSignTx.execute(client); let aliceSignRx = await aliceSignSubmit.getReceipt(client); console.log(`- Status of Alice's signature submission: ${aliceSignRx.status}`); // QUERY TO CONFIRM IF THE SCHEDULE WAS TRIGGERED (SIGNATURES HAVE BEEN ADDED) scheduleQuery = await new ScheduleInfoQuery().setScheduleId(scheduleId).execute(client); console.log(`- Schedule triggered (all required signatures received): ${scheduleQuery.executed !== null}`); // SUBMIT BOB'S SIGNATURE FOR THE TRANSFER TRANSACTION let bobSignTx = await new ScheduleSignTransaction().setScheduleId(scheduleId).freezeWith(client).sign(bobKey); let bobSignSubmit = await bobSignTx.execute(client); let bobSignRx = await bobSignSubmit.getReceipt(client); console.log(`- Status of Bob's signature submission: ${bobSignRx.status}`); // QUERY TO CONFIRM IF THE SCHEDULE WAS TRIGGERED (SIGNATURES HAVE BEEN ADDED) scheduleQuery = await new ScheduleInfoQuery().setScheduleId(scheduleId).execute(client); console.log(`- Schedule triggered (all required signatures received): ${scheduleQuery.executed !== null} \n`); Copy Console output: The scheduled transaction was executed. It is still a good idea to verify that the transfer happened as we expected, so we check all the balances once more to confirm. // VERIFY THAT THE SCHEDULED TRANSACTION (TOKEN TRANSFER) EXECUTED oB = await bCheckerFcn(treasuryId); aB = await bCheckerFcn(aliceId); bB = await bCheckerFcn(bobId); console.log(`- Treasury balance: ${oB[0]} NFTs of ID: ${tokenId} and ${oB[1]}`); console.log(`- Alice balance: ${aB[0]} NFTs of ID: ${tokenId} and ${aB[1]}`); console.log(`- Bob balance: ${bB[0]} NFTs of ID: ${tokenId} and ${bB[1]}`); Copy // BALANCE CHECKER FUNCTION ========================================== async function bCheckerFcn(id) { balanceCheckTx = await new AccountBalanceQuery().setAccountId(id).execute(client); return [balanceCheckTx.tokens._map.get(tokenId.toString()), balanceCheckTx.hbars]; } Copy Console output: Conclusion In this article, you saw examples of the flexibility you get when you create and configure your tokens with HTS - in a transparent and cryptographically provable way. Take advantage of this flexibility to tackle entirely new opportunities in the tokenization industry! Code Check https://github.com/hedera-dev/hedera-example-hts-nft-blog-p1-p2-p3/blob/main/nft-part2.js 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