showing invalid signature in documentation when we create NFT using HTS
INVALID_SIGNATURE on hedera NFT creation
247 Views Asked by Vishal kumar At
3
There are 3 best solutions below
0

That error usually means that the necessary keys are not signing the transaction.
Here's the documentation for creating a token: https://docs.hedera.com/hedera/docs/sdks/tokens/define-a-token
Notice that in the section Transaction Signing Requirements
, the Treasury
, Admin
, and Transaction fee payer
must sign the token create transaction.
Here's a code sample of a token creation being signed by all the above (note that in this case the client is the transaction fee payer. The client signs automatically when the .execute
method is used):
let nftCreate = await new TokenCreateTransaction()
.setTokenName("Fall Collection")
.setTokenSymbol("LEAF")
.setTokenType(TokenType.NonFungibleUnique)
.setDecimals(0)
.setInitialSupply(0)
.setTreasuryAccountId(treasuryId)
.setSupplyType(TokenSupplyType.Finite)
.setMaxSupply(CID.length)
.setCustomFees([nftCustomFee])
.setAdminKey(adminKey)
.setSupplyKey(supplyKey)
.setPauseKey(pauseKey)
.setFreezeKey(freezeKey)
.setWipeKey(wipeKey)
.freezeWith(client)
.sign(treasuryKey);
let nftCreateTxSign = await nftCreate.sign(adminKey);
let nftCreateSubmit = await nftCreateTxSign.execute(client);
let nftCreateRx = await nftCreateSubmit.getReceipt(client);
0

async function main() {
client = Client.forName(process.env.HEDERA_NETWORK).setOperator(
AccountId.fromString(process.env.OPERATOR_ID),
PrivateKey.fromString(process.env.OPERATOR_KEY)
);
// create treasury
const treasuryKey = PrivateKey.generate();
const treasuryId = await createAccount(treasuryKey);
// fee collector
const feeCollectorKey = PrivateKey.generate();
const feeCollectorId = await createAccount(feeCollectorKey);
const supplyKey = PrivateKey.generate();
const adminKey = PrivateKey.generate();
const pauseKey = PrivateKey.generate();
const freezeKey = PrivateKey.generate();
const wipeKey = PrivateKey.generate();
let nftCreate = await new TokenCreateTransaction()
.setTokenName("Collection")
.setTokenSymbol("LEAFTest")
.setTokenType(TokenType.NonFungibleUnique)
.setDecimals(0)
.setInitialSupply(0)
.setTreasuryAccountId(treasuryId)
.setSupplyType(TokenSupplyType.Finite)
.setMaxSupply(100)
.setCustomFees([CreateCustomFeeSchedule(feeCollectorId)])
.setAdminKey(adminKey)
.setSupplyKey(supplyKey)
.setPauseKey(pauseKey)
.setFreezeKey(freezeKey)
.setWipeKey(wipeKey)
.freezeWith(client)
.sign(treasuryKey);
let nftCreateTxSign = await nftCreate.sign(adminKey);
let nftCreateSubmit = await nftCreateTxSign.execute(client);
let nftCreateReceipt = await nftCreateSubmit.getReceipt(client);
console.log(`Token Id ${nftCreateReceipt.tokenId.toString()}`);
console.log("Done");
}
i think you can use the EDSA key for making operaterkey . currently all the hedera development shift to EDSA so make sure you use EDSA key everywhere.
like
const operaterkey = PrivateKey.fromstringEDSA(process.env.operater_key)
const supplyKey = Privatekey.generateEDSA()