2

I can send simple transactions to yoroi without any errors. However when I submit a transaction with NFT policy cardano-cli returns an error.

node version 1.30.1 (relay node)

system: ubuntu 20.4

tip:

{
    "epoch": 296,
    "hash": "32a29af3a31fa24e6d731e9adfeb35eb065eb8f688a611da9b479f2770870a01",
    "slot": 42857090,
    "block": 6380067,
    "era": "Alonzo",
    "syncProgress": "100.00"
}

nft meta :

{
  "721": {
    "policyid": {
      "name": {
        "name": "name",
        "artist": "artist",
        "description": "",
        "image": "ipfs://"
      }
    }
  }
}

create policy

cardano-cli address key-gen \
--verification-key-file policy/policy.vkey \
--signing-key-file policy/policy.skey

keyhash:

cardano-cli address key-hash --payment-verification-key-file policy/policy.vkey

policy script:

{
    "type": "all",
    "scripts": [
        {
            "type": "before",
            "slot": 42862090
        },
        {
            "keyHash": "keyhash",
            "type": "sig"
        }
    ]
}

address:

hash     0        5000000 lovelace + TxOutDatumHashNone

calculate fee:

cardano-cli transaction calculate-min-fee --tx-body-file keys/nfttx.raw --tx-in-count 1 --tx-out-count 2 --witness-count 2 --mainnet --protocol-params-file keys/protocol.json --byron-witness-count 0 

transaction:

cardano-cli transaction build-raw --fee 198721 --tx-in hash#0 --tx-out $(cat keys/payment.addr)+2000000 --tx-out $(cat keys/payment.addr)+2801279+"1 $(cat policy/nft/policy.id).head00" --mint="1 $(cat policy/nft/policy.id).head00" --minting-script-file policy/nft/nft_policy.script --metadata-json-file policy/nft/nft_meta.json --invalid-hereafter=42862090 --out-file keys/nfttx.raw --invalid-before 42857090

sign transaction

cardano-cli transaction sign  --tx-body-file keys/nfttx.raw  --signing-key-file keys/payment.skey --mainnet  --out-file keys/tx.signed

error:

Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (ScriptWitnessNotValidatingUTXOW (fromList [ScriptHash "keyhash"])))])

EDIT: I get the same error even when submitting a transaction without the invalidation of the policy script part.

4
  • Please add add the commands that your are executing
    – raghu
    Commented Oct 18, 2021 at 6:04
  • @raghu I think I forgot signing the transaction with my policy.skey. If you update your answer I'll accept it.
    – Bahamas
    Commented Oct 18, 2021 at 8:10
  • I'm having the same problem. Did you find a solution?
    – cardadodev
    Commented Oct 27, 2021 at 3:36
  • @cardadodev The transaction needs to be signed with the policy.skey and the payment.skey together.
    – Bahamas
    Commented Nov 16, 2021 at 0:09

2 Answers 2

2

Would you mind changing the

`"keyHash": "keyhash",

in the policy script with you key hash. You can generate key hash using

cardano-cli address key-hash --payment-verification-key-file policy.vkey

exact command will depend on the location of your key files.

After including this Key Hash in the policy script, the minting transaction must be signed by the corresponding signing ket(policy.skey). The transaction also has to be signed by the wallet which is paying the fee. Unless these two signing keys are proper the transaction will not get submitted.

2
  • 1
    I just changed it for the question. I put the correct keyhash in the script.
    – Bahamas
    Commented Oct 17, 2021 at 19:44
  • 2
    @Bahamas so why did you accept this answer if it didn't help you?
    – Petr
    Commented Dec 30, 2021 at 19:03
2

I also got this error trying to mint a native token. In my case, adding the invalid-hereafter parameter to the cardano-cli transaction build-raw command fixed it. I made sure the value was the same slot number as the policy script before value.

I did not include the invalid-before parameter like the OP.

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.