2

showing invalid signature in documentation when we create NFT using HTS

This is what am using to create the signature

want to create NFT using HTS HEDERA TOKEN SERVICES

  • Please don't post images (or links to images) of code or errors. Anything text-based (code and errors) should be posted directly into the question and [formatted properly](https://stackoverflow.com/help/formatting). By posting images we are not able to copy your code to reproduce it. Also, it is not searchable so others can find your question easily. For more, see [Why should I not upload images of code/data/errors?](https://meta.stackoverflow.com/q/285551/6045800) – Tomerikoo Feb 07 '23 at 15:31

3 Answers3

0

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()

  • by doing this you can genrate the HTS token – VISHAL KUMAR Jan 07 '23 at 14:18
  • Hi, Hedera isn't technically shifting from ED25519 to ECDSA, both are valid, however ECDSA provides more compatibility with smart contracts, as well as compatibility with wallets such as MetaMask. Given Hedera is working towards EVM equivalence, support for ECDSA keys was necessary but doesn't replace ED25519 keys. – Greg Scullard Feb 07 '23 at 15:27
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);
Ed Marquez
  • 488
  • 1
  • 10
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");
}
Greg Scullard
  • 241
  • 1
  • 10