Hedera
  • Welcome to Hedera — let’s build the future
  • Getting Started
    • Environment Setup
    • Web2 Developers
      • Transfer HBAR
      • Create a Token
      • Create a Topic
    • EVM Developers
      • Deploy a Contract
  • Tutorials
    • Smart Contracts
      • How to Mint & Burn an ERC-721 Token Using Hardhat and Ethers (Part 1)
      • How to Set Access Control, a Token URI, Pause, and Transfer an ERC-721 Token Using Hardhat (Part 2)
      • How to Upgrade an ERC-721 Token with OpenZeppelin UUPS Proxies and Hardhat (Part 3)
      • How to Verify a Smart Contract on HashScan
      • Deploy a Smart Contract Using Remix
      • Deploy a Smart Contract Using Hardhat and Hiero JSON-RPC Relay
      • Deploy Your First Smart Contract
      • Deploy a Contract Using the Hedera Token Service
      • Send and Receive HBAR Using Solidity Smart Contracts
      • Deploy By Leveraging Ethereum Developer Tools On Hedera
      • Deploy a Subgraph Using The Graph and Hedera JSON-RPC Relay
      • Deploy Smart Contracts on Hedera Using Truffle
      • The Power of Native Hedera Tokens as ERC-20 Tokens: A step-by-step guide
      • HTS x EVM - Part 1: How to Mint NFTs
      • HTS x EVM - Part 2: KYC & Update
      • HTS x EVM - Part 3: How to Pause, Freeze, Wipe, and Delete NFTs
      • Hedera Smart Contracts Workshop
        • Setup
        • Solidity
        • Hedera SDK JS
        • Hardhat and EthersJs
        • Outro
      • Foundry
        • How to Setup Foundry and Write a Basic Unit Test
        • How to Deploy and Verify a Hedera Smart Contract with Foundry
        • How to Test A Solidity Event
        • How to Fork Testnet on Latest Block
    • Consensus
      • Submit Your First Message
      • Submit Message to Private Topic
      • Query Messages with Mirror Node
    • Tokens
      • Create and Transfer Your First NFT
      • Create and Transfer Your First Fungible Token
      • Create and Transfer an NFT using a Solidity Contract
      • Structure Your Token Metadata Using JSON Schema V2
      • Hedera Token Service - Part 1: How to Mint NFTs
      • Hedera Token Service - Part 2: KYC, Update, and Scheduled Transactions
      • Hedera Token Service - Part 3: How to Pause, Freeze, Wipe, and Delete NFTs
      • Create Your First Frictionless Airdrop Campaign
    • Local Node
      • How to Run Hedera Local Node in a Cloud Development Environment (CDE)
        • Run a Local Node in Gitpod
        • Run a Local Node in Codespaces
      • How to Set Up a Hedera Local Node
      • Set Up a Hedera Local Node using the NPM CLI
    • More Tutorials
      • Create and Fund Your Hedera Testnet Account
      • How to Create a Personal Access Token (API Key) on the Hedera Portal
      • How to Auto-Create Hedera Accounts with HBAR and Token Transfers
      • How to Configure a Mirror Node and Query Data
      • How to Generate a Random Number on Hedera
      • Get Started with the Hedera Consensus Service Fabric Plugin
        • Virtual Environment Setup
      • Schedule Your First Transaction
      • How to Connect to Hedera Networks Over RPC
        • Configuring Hashio RPC endpoints
        • Configuring Hiero JSON-RPC Relay endpoints
        • Configuring Validation Cloud RPC endpoints
      • JavaScript Testing
      • Create a Hedera DApp Integrated with WalletConnect
      • How to Connect MetaMask to Hedera
    • Demo Applications
    • Starter Projects
    • Building on Hedera (course)
  • Networks
    • Mainnet
      • Mainnet Accounts
      • Mainnet Consensus Nodes
        • Node Requirements
          • FAQ
      • Fees
        • Transaction Records
    • Testnets
      • Testnet Accounts
      • Testnet Consensus Nodes
    • Localnet
      • Single Node Configuration
      • Multinode Configuration
    • Network Explorers and Tools
    • Release Notes
      • Consensus Node
      • Hedera Mirror Node
  • Core Concepts
    • Accounts
      • Account Creation
      • Auto Account Creation
      • Account Properties
    • Keys and Signatures
    • Schedule Transaction
    • Smart Contracts
      • Understanding Hedera's EVM Differences and Compatibility
        • For EVM Developers Migrating to Hedera
          • Accounts, Signature Verification & Keys (ECDSA vs. ED25519)
          • JSON-RPC Relay and EVM Tooling
          • Token Management with Hedera Token Service
          • Decimal Handling (8 vs. 18 Decimals)
          • Handling HBAR Transfers in Contracts
        • For Hedera-Native Developers Adding Smart Contract Functionality
          • Integrating ED25519 Accounts and Advanced Features Into Smart Contracts
          • JSON-RPC Relay and State Queries
          • Extending Token Management with Smart Contracts
      • Creating Smart Contracts
      • Compiling Smart Contracts
      • System Smart Contracts
        • Hedera Account Service
        • Hedera Schedule Service
      • Gas and Fees
      • JSON-RPC Relay
      • Deploying Smart Contracts
      • Smart Contract Addresses
      • Verifying Smart Contracts
      • Smart Contract Traceability
      • Tokens Managed by Smart Contracts
        • ERC-20 (Fungible Tokens)
        • ERC-721 (Non-Fungible Token)
        • ERC-3643 Real World Assets (RWA)
        • ERC-1363 (Payable Tokens)
        • Hedera Token Service System Contract
      • Wrapped HBAR (WHBAR)
      • Smart Contract Rent
      • Smart Contract Security
      • EVM Archive Node Queries
    • Tokens
      • Tokenization on Hedera
      • Hedera Token Service (HTS) Native Tokenization
        • Token Types and ID Formats
        • Token Properties
        • Token Creation
        • Custom Fee Schedule
        • Token Airdrops
      • ERC/EVM-Compatible Tokenization
      • Hybrid (HTS + EVM ) Tokenization
    • Staking
      • Staking Program
      • Stake HBAR
    • Hashgraph Consensus Algorithm
      • Gossip About Gossip
      • Virtual Voting
    • Transactions and Queries
      • Transaction Properties
    • State and History
    • Mirror Nodes
      • Hedera Mirror Node
      • One Click Mirror Node Deployment
      • Run Your Own Mirror Node
        • Run Your Own Mirror Node with Google Cloud Storage (GCS)
        • Run Your Mirror Node with Amazon Web Services S3 (AWS)
  • Open Source Solutions and Integrations
    • AI Studio on Hedera
      • ElizaOS Plugin for Hedera
      • Hedera AI Agent Kit
      • MCP Server
      • OpenConvAI
    • AI Tools for Developers
      • Hedera Hivemind
      • Kapa AI
    • Asset Tokenization Studio (ATS)
      • Web User Interface (UI)
      • Frequently Asked Questions (FAQs)
    • HashioDAO
      • Governance Token DAO
      • NFT DAO
      • Multisig DAO
      • DAO Proposals
      • Local Environment Setup
    • Hedera CLI
    • Hedera Contract Builder
    • Hedera Custodians Library
      • How to use it
    • Hedera Developers Code Repository
    • Hedera Developer Playground
    • Hedera Wallet Snap By MetaMask
      • Hedera Wallet Snap Documentation
      • Tutorial: MetaMask Snaps – What Are They and How to Use Them
    • Interoperability and Bridging
      • LayerZero
    • NFT Studio
      • Airdrop List Verifier
      • Metadata Validator
      • NFT Rarity Inspector
      • NFT Token Holders List Builder
      • NFT Risk Calculator
      • Token Balance Snapshot
      • Hedera NFT SDK
    • Oracle Networks
      • Chainlink Oracles
      • Pyth Oracles
      • Supra Oracles
    • Stablecoin Studio
      • Core Concepts
      • Web UI Application
      • CLI Management
      • TypeScript SDK
    • Hedera Guardian
    • Hedera WalletConnect
  • SDKs & APIs
    • SDKs
      • Build Your Hedera Client
      • Set Up Your Local Network
      • Network Address Book
      • Keys
        • Generate a new key pair
        • Import an existing key
        • Create a key list
        • Create a threshold key
        • Generate a mnemonic phrase
        • Recover keys from a mnemonic phrase
      • HBAR
      • Specialized Types
      • Pseudorandom Number Generator
      • Transactions
        • Create a Batch Transaction
        • Transaction ID
        • Modify transaction fields
        • Create an unsigned transaction
        • Manually sign a transaction
        • Submit a transaction
        • Sign a multisignature transaction
        • Get a transaction receipt
        • Get a transaction record
      • Schedule Transaction
        • Schedule ID
        • Create a schedule transaction
        • Sign a scheduled transaction
        • Delete a schedule transaction
        • Get schedule info
        • Network Response Messages
      • Queries
      • General Network Response Messages
      • Accounts and HBAR
        • Create an account
        • Update an account
        • Transfer cryptocurrency
        • Approve an allowance
        • Delete an allowance
        • Delete an account
        • Get account balance
        • Get account info
        • Network Response Messages
      • Consensus Service
        • Create a topic
        • Update a topic
        • Submit a message
        • Delete a topic
        • Get topic messages
        • Get topic info
        • Network Response
      • Token Service
        • Token ID
        • NFT ID
        • Token types
        • Create a token
        • Custom token fees
        • Update a token
        • Update token custom fees
        • Update NFT metadata
        • Transfer tokens
        • Airdrop a token
        • Claim a token
        • Cancel a token
        • Reject a token
        • Delete a token
        • Mint a token
        • Burn a token
        • Freeze an account
        • Unfreeze an account
        • Enable KYC account flag
        • Disable KYC account flag
        • Associate tokens to an account
        • Dissociate tokens from an account
        • Pause a token
        • Unpause a token
        • Wipe a token
        • Atomic swaps
        • Get account token balance
        • Get token info
        • Get NFT info
        • Network Response Messages
      • File Service
        • Create a file
        • Append to a file
        • Update a file
        • Delete a file
        • Get file contents
        • Get file info
        • Network Response Messages
      • Smart Contract Service
        • Delegate Contract ID
        • Create a smart contract
        • Update a smart contract
        • Delete a smart contract
        • Call a smart contract function
        • Ethereum transaction
        • Get a smart contract function
        • Get smart contract bytecode
        • Get smart contract info
        • Hedera Service Solidity Libraries
        • Network Response Messages
      • Signature Provider
        • Provider
        • Signer
        • Wallet
        • Local Provider
    • Mirror Node REST API
      • Accounts
      • Balances
      • Blocks
      • Schedule Transactions
      • Smart Contracts
      • Tokens
      • Topics
      • Transactions
      • Network
    • Hedera Consensus Service gRPC API
    • Hedera APIs
      • Basic Types
        • AccountAmount
        • AccountID
        • ContractID
        • CryptoAllowance
        • CurrentAndNextFeeSchedule
        • FeeComponents
        • FeeData
        • FeeSchedule
        • FileID
        • Fraction
        • HederaFunctionality
        • Key
        • KeyList
        • NftAllowance
        • NftTransfer
        • NodeAddress
        • NodeAddressBook
        • RealmID
        • ScheduleID
        • SemanticVersion
        • ServicesConfigurationList
        • ServiceEndpoint
        • Setting
        • ShardID
        • Signature
        • SignatureList
        • SignatureMap
        • SignaturePair
        • SubType
        • TransferList
        • TransactionID
        • ThresholdKey
        • ThresholdSignature
        • TokenAllowance
        • TokenBalance
        • TokenBalances
        • TokenFreezeStatus
        • TokenPauseStatus
        • TokenID
        • TokenKycStatus
        • TokenRelationship
        • TokenTransferList
        • TokenType
        • TokenSupplyType
        • TopicID
        • TransactionFeeSchedule
      • Cryptocurrency Accounts
        • CryptoService
        • CryptApproveAllowance
        • CryptoDeleteAllowance
        • CryptoCreate
        • CryptoTransfer
        • CryptoUpdate
        • CryptoDelete
        • CryptoGetAccountBalance
        • CryptoGetAccountRecords
        • CryptoGetInfo
        • CryptoGetStakers
      • Consensus Service
        • Consensus Service
        • ConsensusCreateTopic
        • ConsensusUpdateTopic
        • ConsensusSubmitMessage
        • ConsensusDeleteTopic
        • ConsensusTopicInfo
        • ConsensusGetTopicInfo
      • Schedule Service
        • ScheduleService
        • SchedulableTransactionBody
        • ScheduleCreate
        • ScheduleDelete
        • ScheduleSign
        • ScheduleGetInfo
      • Token Service
        • TokenService
        • CustomFees
          • AssessedCustomFee
          • CustomFee
          • FractionalFee
          • FixedFee
          • RoyaltyFee
        • TokenCreate
        • TokenUpdate
        • TokenFeeScheduleUpdate
        • TokenDelete
        • TokenMint
        • TokenBurn
        • TokenFreezeAccount
        • TokenUnfreezeAccount
        • TokenGrantKyc
        • TokenRevokeKyc
        • TokenAssociate
        • TokenDissociate
        • TokenWipeAccount
        • TokenPause
        • TokenUnpause
        • TokenGetInfo
        • TokenGetNftInfo
        • TokenGetNftInfos
        • TokenGetAccountNftInfo
      • File Service
        • FileService
        • FileCreate
        • FileAppend
        • FileUpdate
        • FileDelete
        • FileGetContents
        • FileGetInfo
      • Smart Contracts
        • SmartContractService
        • ContractCall
        • ContractCallLocal
        • ContractCreate
        • ContractUpdate
        • ContractDelete
        • ContractGetByteCode
        • ContractGetInfo
        • ContractGetRecords
      • Miscellaneous
        • Duration
        • ExchangeRate
        • Freeze
        • FreezeType
        • GetByKey
        • GetBySolidityID
        • NetworkGetVersionInfo
        • NetworkService
        • Query
        • QueryHeader
        • Response
        • ResponseCode
        • ResponseHeader
        • SystemDelete
        • SystemUndelete
        • TimeStamp
        • Transaction
        • TransactionBody
        • TransactionContents
        • TransactionGetFastRecord
        • TransactionGetReceipt
        • TransactionGetRecord
        • TransactionReceipt
        • TransactionRecord
        • TransactionResponse
        • UncheckedSubmit
    • Hedera Status API
  • Support & Community
    • Glossary
    • Contributing to Hedera documentation
      • Contribution Guidelines
        • Creating Issues
        • Creating Pull Requests
        • Hedera Improvement Proposal (HIP)
        • Submit Demo Applications
      • Style Guide
        • Understanding different types of documentation
        • Use of HBAR and tinybars
        • Use of web2 and web3
        • Language and grammar
        • Formatting
        • Punctuation
        • GitBook Markdown Syntax
    • Discord
    • GitHub
    • Stack Overflow
    • Hedera Blog
    • Bug Bounty
    • Hedera Help
    • Documentation Survey
    • Meetups
    • Brand Guidelines
    • Status Page
Powered by GitBook
LogoLogo

INTRODUCTION

  • Fees
  • Core Concepts
  • Network Information

TOOLS

  • Bridge
  • Oracles
  • Explorers
  • Developer Portal & Faucet

RESOURCES

  • Status
  • Bug Bounty
  • Build on Hedera (course)
  • Documentation Survey
On this page
  • Prerequisites
  • Table of Contents
  • Step 1: Project Setup
  • Step 2. Creating an NFT
  • Step 3. Minting an NFT
  • Step 4. Transferring NFTs
  • Step 5. Burning an NFT
  • Conclusion
  • Additional Resources

Was this helpful?

Edit on GitHub
  1. Tutorials
  2. Smart Contracts

HTS x EVM - Part 1: How to Mint NFTs

PreviousThe Power of Native Hedera Tokens as ERC-20 Tokens: A step-by-step guideNextHTS x EVM - Part 2: KYC & Update

Last updated 1 month ago

Was this helpful?

In , we showed how to create, mint, burn, and transfer non-fungible tokens (NFTs) on Hedera without deploying any smart contracts—using only the Hedera Token Service (HTS) and official SDKs.

It's possible to create a token on Hedera using a smart contract and still benefit from the native Hedera Token Service. However, the contract needs to interact with the , which provides Hedera-specific token operations. By combining HTS and Solidity, you:

  • Get all the performance, cost-efficiency, and security of native HTS tokens.

  • Can embed custom, decentralized logic in your contract for advanced use cases.

In this tutorial, you’ll:

  • Create an NFT collection with a royalty fee schedule.

  • Mint new NFTs with metadata pointing to IPFS.

  • Transfer NFTs.

  • Burn an existing NFT.


Prerequisites

  • ECDSA account from the .

  • Basic understanding of Solidity.


Table of Contents


Step 1: Project Setup

  1. Clone the repository

git clone https://github.com/hedera-dev/hts-evm-hybrid-mint-nfts.git
cd hts-evm-hybrid-mint-nfts
  1. Install dependencies

npm install
  1. Create .env file set up environment variables

cp .env.example .env

Edit the .env file to include your Hedera Testnet account's private key. Use your ECDSA Hex Encoded Private Key when interacting with Hedera's EVM via the JSON-RPC relay.

PRIVATE_KEY=0x
  1. Run the test script

npx hardhat test test/1-MintNFT.ts

This script deploys and tests all of the functionality inside of the MintNFT Smart Contract. We'll deep dive into the Smart Contract's functions and corresponding tests below!


Step 2. Creating an NFT

Function: createNFT(string memory name, string memory symbol, string memory memo)

Purpose: Deploy a Hedera NFT using Solidity. This involves specifying key token details (name, symbol, and memo), as well as setting up any custom fees (such as royalty fees).

Key Code Snippet:

contracts/1-MintNFT.sol
function createNFT(
    string memory name,
    string memory symbol,
    string memory memo
) external payable onlyOwner {
    // Create the royalty fee
    IHederaTokenService.RoyaltyFee[] memory royaltyFees =
        new IHederaTokenService.RoyaltyFee[](1);
    royaltyFees[0] = IHederaTokenService.RoyaltyFee({
        numerator: 1,
        denominator: 10,
        amount: 100000000,  // Fallback fee of 1 HBAR in tinybars (1 HBAR = 1e8 tinybars)
        tokenId: address(0),
        useHbarsForPayment: true,
        feeCollector: owner
    });

    // Create fixed fees array (empty for this example)
    IHederaTokenService.FixedFee[] memory fixedFees =
        new IHederaTokenService.FixedFee[](0);

    // Create the token definition
    IHederaTokenService.HederaToken memory token;
    token.name = name;
    token.symbol = symbol;
    token.memo = memo;
    token.treasury = address(this);

    // Set the supply key (the contract itself)
    IHederaTokenService.TokenKey[] memory keys =
        new IHederaTokenService.TokenKey[](1);
    keys[0] = getSingleKey(
        KeyType.SUPPLY,
        KeyValueType.CONTRACT_ID,
        address(this)
    );
    token.tokenKeys = keys;

    (int responseCode, address createdToken) =
        createNonFungibleTokenWithCustomFees(token, fixedFees, royaltyFees);

    require(
        responseCode == HederaResponseCodes.SUCCESS,
        "Failed to create NFT"
    );

    tokenAddress = createdToken;
    emit NFTCreated(createdToken);
}

How It Works

  1. Prepare a Royalty Fee: We define a single royalty fee in royaltyFees[0] to collect 1/10th (10%) of the value exchanged in any subsequent NFT transfer. If there is no fungible value in the transfer, a fallback fee of 1 HBAR is charged.

  2. Build the Token Definition: The token name, symbol, memo, and treasury address are assembled into a HederaToken struct. Since this token is a non-fungible token, decimals default to zero.

  3. Set the Supply Key: By assigning the contract’s address (address(this)) as the SUPPLY key, only this contract can mint or burn new tokens.

  4. Emit NFTCreated: On success, we store the tokenAddress for later use and emit an event for off-chain indexing or debugging.

Test Implementation

it("should create an NFT", async () => {
  // Deploy the MintNFT contract earlier, then call createNFT:
  const mintTx = await mintNftContract.createNFT("Test NFT", "TST", "Test NFT", {
    gasLimit: 250_000,
    value: ethers.parseEther("7") // HBAR needed to pay for token creation fee
  });

  await expect(mintTx)
    .to.emit(mintNftContract, "NFTCreated")
    .withArgs(ethers.isAddress);
});

Here, we pass "Test NFT", "TST", and "Test NFT" as arguments. We also send some HBAR (in this case, 7 HBAR) to cover the creation costs on the Hedera network. We expect the NFTCreated event to have a valid token address to confirm success.

Note


Step 3. Minting an NFT

Function: mintNFT(bytes[] memory metadata)

Purpose: Add new tokens to the existing NFT collection. Each minted token includes a unique piece of metadata (for instance, an IPFS URI).

Key Code Snippet:

contracts/1-MintNft.sol
function mintNFT(bytes[] memory metadata) external onlyOwner {
    require(tokenAddress != address(0), "Token not created yet");

    (
        int responseCode,
        int64 newTotalSupply,
        int64[] memory serialNumbers
    ) = mintToken(tokenAddress, 0, metadata);

    require(responseCode == HederaResponseCodes.SUCCESS, "Failed to mint NFT");
    emit NFTMinted(newTotalSupply, serialNumbers);
}

How It Works

  1. Call mintToken: This HTS System Contract function creates new NFT serial numbers for each entry in the metadata array. For example, if you pass three metadata values, you will mint three (3) unique NFTs.

  2. Emit NFTMinted: Returns the newTotalSupply and the array of serialNumbers corresponding to the newly minted tokens.

Test Implementation

test/1-MintNFT.ts
it("should mint an NFT with metadata", async () => {
  // Example single metadata entry (an IPFS URI)
  const metadata = [
    ethers.toUtf8Bytes("ipfs://bafkreibr7cyxmy4iyc...") 
  ];

  const mintTx = await mintNftContract.mintNFT(metadata, {
    gasLimit: 350_000
  });

  await expect(mintTx)
    .to.emit(mintNftContract, "NFTMinted");
});

We pass an array with one IPFS URI (encoded as bytes). The test expects an NFTMinted event on success, indicating new tokens are now part of our NFT supply.


Step 4. Transferring NFTs

Function: transferNFT(address receiver, uint256 serialNumber)

Purpose: Transfer an existing NFT from the contract’s treasury (in this case, address(this)) to another address. This leverages the standard ERC-721 transfer pattern.

Key Code Snippet:

contracts/1-MintNft.sol
function transferNFT(address receiver, uint256 serialNumber) external {
    require(tokenAddress != address(0), "Token not created yet");
    IERC721(tokenAddress).transferFrom(
        address(this),
        receiver,
        serialNumber
    );
    emit NFTTransferred(receiver, serialNumber);
}

How it Works

  1. Checks Token Address: Again, ensure the contract has already created the token.

  2. ERC-721 transferFrom: Since Native Hedera Tokens can be treated as though they are ERC-721, we call transferFrom(this, receiver, serialNumber) to move the NFT from the contract to the specified address.

  3. Emit NFTTransferred: Logs the receiving address and the token’s serialNumber.

Test Implementation

test /1-MintNFT.ts
it("should transfer the NFT to owner", async () => {
  const [owner] = await ethers.getSigners();
  const serialNumber = 1n; // the 'n' notation is shorthand to declare a BigInt type. This represents the first minted NFT

  const transferTx = await mintNftContract.transferNFT(owner.address, serialNumber, {
    gasLimit: 350_000
  });

  await expect(transferTx)
    .to.emit(mintNftContract, "NFTTransferred")
    .withArgs(owner.address, serialNumber);
});

Here, we transfer serial #1 from the contract to the owner address. On success, we expect the NFTTransferred event. We can also verify ownership using the standard IERC721(tokenAddress).ownerOf(serialNumber) call.

Hedera Native Tokens are highly interoperable with their corresponding ERC Contracts. In the code snippet below we show that Hedera Accounts are able to transfer native NFTs as though they are ERC-721 Smart Contracts!

test /1-MintNFT.ts
it("should transfer the NFT back to contract before burning", async () => {
    const [owner] = await ethers.getSigners();
    const serialNumber = 1n;
    const tokenAddress = await mintNftContract.getTokenAddress();

    // Get the NFT contract interface
    const nftContract = await ethers.getContractAt("IERC721", tokenAddress);

    // Then transfer from owner back to contract
    await nftContract.transferFrom(
      owner.address,
      mintNftContract.target,
      serialNumber,
      {
        gasLimit: 350_000
      }
    );

    // Verify the NFT is now owned by the contract
    expect(await nftContract.ownerOf(serialNumber))
      .to.equal(mintNftContract.target);
  });

Step 5. Burning an NFT

Function: burnNFT(int64[] memory serialNumbers)

Purpose: Burn (permanently remove) existing NFTs from circulation. This is helpful if you need to remove misprints, decommission tokens, or reduce supply to increase rarity. The serials must be in the Treasury account in order to burn them.

Key Code Snippet:

contracts/1-MintNft.sol
function burnNFT(int64[] memory serialNumbers) external onlyOwner {
    require(tokenAddress != address(0), "Token not created yet");

    (int responseCode, int64 newTotalSupply) =
        burnToken(tokenAddress, 0, serialNumbers);

    require(responseCode == HederaResponseCodes.SUCCESS, "Failed to burn NFT");
    emit NFTBurned(responseCode, newTotalSupply);
}

Test Implementation

test /1-MintNFT.ts
it("should burn the minted NFT", async () => {
  // Assume serial 1 NFT has been returned to the Contract
  const serialNumbers = [1n];

  const burnTx = await mintNftContract.burnNFT(serialNumbers, {
    gasLimit: 60_000
  });

  await expect(burnTx)
    .to.emit(mintNftContract, "NFTBurned");
});

We pass an array of serial numbers—in this case, [1n] for the first minted NFT. The test ensures that NFTBurned fires, confirming the token is removed from the supply.


Conclusion

Using Solidity on Hedera, you can create, mint, burn, and transfer native NFTs with minimal code thanks to the HTS System Contract. In this tutorial, you saw how to:

  • Create a new NFT class with royalty fees (createNFT).

  • Mint new tokens (mintNFT).

  • Burn tokens when they are no longer needed (burnNFT).

  • Transfer NFTs via standard ERC-721 calls (transferNFT).


Additional Resources

Check out our GitHub repo to find the full contract and Hardhat test scripts, along with the configuration files you need to deploy and test on Hedera!

Make sure to use an ECDSA account with for the test script to run successfully.

Create the NFT: Calling createNonFungibleTokenWithCustomFees(...) triggers the The call returns a response code and the token address (unique ID for the NFT class).

For most HTS calls, an HBAR value is not required to be sent in the contract call; the gas fee will cover it. However, for expensive transactions, like , the gas fee is reduced, and the transaction cost is covered by the payable amount. This is to reduce the gas consumed by the contract call.

As you can see, despite our NFT not actually being an ERC-721 (it is a Native Token; not a Smart Contract), we can treat it as though it is one. The same goes for Native Fungible Tokens and ERC-20 interfaces. Find out more .

Continue exploring our to see how advanced compliance flags (e.g., KYC) or updating tokens can be handled natively.

System Smart Contract
Create Token Transactions
here
Part 2: KYC & Update
HTS x EVM - Part 2: KYC & Update
Full Contract and Hardhat Test Scripts Repository
Hedera Token Service - Part 1: How to Mint NFTs
HTS System Contract
Hedera Portal
Project Setup
Creating an NFT
Minting an NFT
Transferring an NFT
Burning an NFT
Conclusion
Additional Resources

Writer: Jake, Developer Relations Engineer

Editor: Michiel, Developer Relations Engineer

Editor: Krystal, Technical Writer

|

|

|

GitHub
X
GitHub
LinkedIn
GitHub
X
HTS System Smart Contract.
Unlimited Auto-Associations