0

Having an issue trying to mint an NFT with my own policy. It's throwing the error below:

Missing key witness for: 1e101f14d07f203b01f8.....

I am not sure what to do here and any assistance would be appreciated. Long time developer, short time developing on Cardano.

Here is my code:

const nativeScript: NativeScript = {
  type: 'all',
  scripts:
  [
     {
      type: 'sig',
      keyHash: '1e101f14d07f203b01f89d1562831374f....'
    },
    {
      type: 'before',
      slot: '317614504'
    }
   
  ]
};

const forgingScript = ForgeScript.fromNativeScript(nativeScript);

const { wallet, connected } = useWallet();
const [txHash, setTxHash] = useState<string | null>(null);
const [loading, setLoading] = useState<boolean>(false);

 const wallet_for_mint = new AppWallet({
    networkId: 1,
    fetcher: blockchainProvider,
    submitter: blockchainProvider,
    key: {
      type: "mnemonic",
      words: [
    'tenant',
....
      ],
    },
  });


 const assetMetadata1: AssetMetadata = {
      name: "ASSETNAME",
      type: "TYPE1",
      item: "FLAG",
      image: "ipfs://Qmb18wvCu.....",
    };

    const asset1: Mint = {
      assetName: "TESTASSET",
      assetQuantity: "1",
      metadata: assetMetadata1,
      label: "721",
      recipient:
   
      "addr.........e",
    };


    

    const txMint = new Transaction({ initiator: wallet_for_mint });
    txMint.mintAsset(forgingScript, asset1);

    const unsignedTxMint = await txMint.build();
    const signedTxMint = await wallet_for_mint.signTx(unsignedTxMint);
    const txHash = await wallet_for_mint.submitTx(signedTxMint);

2
  • Is this all the code? Where do you set the witness count?
    – PREEB
    Mar 21, 2023 at 20:35
  • Hey. Thanks for the reply. That is all the code. I dont see in the sample code where the witness count is set. Mar 22, 2023 at 9:41

1 Answer 1

0

It appears that you need to call one of the signature methods from ForgeScript. In most of the examples, they use ForgeScript.withOneSignature(address). However there are multiple options:

  1. withOneSignature
  2. withAtLeastNSignatures
  3. withAnySignature
  4. withAllSignatures

This looks like it needs to be done before your call to ForgeScript.fromNativeScript(nativeScript). This might set the witness count in some way.

"The --witness-count 1 basically tells cardano-cli that there will be only 1 signing key required for this transaction to be valid. Since the UTXO input involved in this transaction will only be coming from payment1 wallet, so that means we indeed only need 1 key to sign the transaction." https://developers.cardano.org/docs/integrate-cardano/creating-wallet-faucet

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.