Encountering INVALID_SIGNATURE error when creating NFTs on Hedera

Hey everyone,

I’m having trouble creating NFTs using Hedera Token Service (HTS). Every time I try, I get an INVALID_SIGNATURE error. I’ve been following the documentation, but something’s not clicking.

Here’s what I’ve been doing:

const privateKey = PrivateKey.fromString(process.env.PRIVATE_KEY);
const publicKey = privateKey.publicKey;

const nftCreate = await new TokenCreateTransaction()
  .setTokenName('MyNFT')
  .setTokenSymbol('MNFT')
  .setTokenType(TokenType.NonFungibleUnique)
  .setSupplyType(TokenSupplyType.Finite)
  .setInitialSupply(0)
  .setMaxSupply(5)
  .setTreasuryAccountId(treasuryId)
  .setAdminKey(adminKey)
  .setSupplyKey(supplyKey)
  .freezeWith(client)
  .sign(privateKey);

const nftCreateTxResponse = await nftCreate.execute(client);
const receipt = await nftCreateTxResponse.getReceipt(client);

Can anyone spot what I’m doing wrong? I’m pretty sure my key setup is correct, but maybe I’m missing something obvious. Any help would be awesome!

I encountered a similar issue when creating NFTs on Hedera. One crucial step that’s often overlooked is setting the Treasury Account as the fee payer. Try adding .setTransactionValidDuration(120) and .freezeWith(client) before signing. Also, ensure your account has sufficient HBAR balance for the transaction fees. If the problem persists, you might want to verify the network you’re connecting to matches your account network. Lastly, double-check that you’re using the latest SDK version, as older versions sometimes cause unexpected errors with newer network features.

have u checked if ur private key matches the account ID ur using? sometimes that can cause INVALID_SIGNATURE. also, make sure ur client is properly initialized with the right network (testnet/mainnet). might be worth double-checking ur env variables too. good luck!

hey Ben_Comics, thanks for sharing your code! im also working with NFTs on Hedera and ran into similar issues. have you considered using the signWithOperator() method instead of sign()? it worked better for me in some cases. also, are you sure all your key variables (adminKey, supplyKey) are properly defined?

btw, what kind of NFTs are you creating? sounds like an interesting project! id love to hear more about it if youre willing to share :slight_smile: maybe we could exchange some tips on working with Hedera?