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

CC BY-SA 4.0
2022-07-19T13:48:59.000Z
2022-07-19T13:48:59.000Z
Kurt Hartmann
<p>Would you mind changing the</p>
<blockquote>
<p>`&quot;keyHash&quot;: &quot;keyhash&quot;,</p>
</blockquote>
<p>in the policy script with you key hash. You can generate key hash using</p>
<blockquote>
<p><code>cardano-cli address key-hash --payment-verification-key-file policy.vkey</code></p>
</blockquote>
<p>exact command will depend on the location of your key files.</p>
<p>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.</p>

CC BY-SA 4.0
2021-10-17T19:44:19.207Z
I just changed it for the question. I put the correct keyhash in the script.
Bahamas
CC BY-SA 4.0
2021-12-30T19:03:39.863Z
@Bahamas so why did you accept this answer if it didn't help you?
Petr
CC BY-SA 4.0
2021-10-17T17:20:28.860Z
2021-10-18T08:20:37.767Z
2021-10-18T08:20:37.767Z
raghu
<p>I can send simple transactions to yoroi without any errors. However when I submit a transaction with NFT policy cardano-cli returns an error.</p>
<p>node version 1.30.1 (relay node)</p>
<p>system: ubuntu 20.4</p>
<p>tip:</p>
<pre><code>{
    &quot;epoch&quot;: 296,
    &quot;hash&quot;: &quot;32a29af3a31fa24e6d731e9adfeb35eb065eb8f688a611da9b479f2770870a01&quot;,
    &quot;slot&quot;: 42857090,
    &quot;block&quot;: 6380067,
    &quot;era&quot;: &quot;Alonzo&quot;,
    &quot;syncProgress&quot;: &quot;100.00&quot;
}
</code></pre>
<p>nft meta :</p>
<pre><code>{
  &quot;721&quot;: {
    &quot;policyid&quot;: {
      &quot;name&quot;: {
        &quot;name&quot;: &quot;name&quot;,
        &quot;artist&quot;: &quot;artist&quot;,
        &quot;description&quot;: &quot;&quot;,
        &quot;image&quot;: &quot;ipfs://&quot;
      }
    }
  }
}
</code></pre>
<p>create policy</p>
<pre><code>cardano-cli address key-gen \
--verification-key-file policy/policy.vkey \
--signing-key-file policy/policy.skey
</code></pre>
<p>keyhash:</p>
<pre><code>cardano-cli address key-hash --payment-verification-key-file policy/policy.vkey
</code></pre>
<p>policy script:</p>
<pre><code>{
    &quot;type&quot;: &quot;all&quot;,
    &quot;scripts&quot;: [
        {
            &quot;type&quot;: &quot;before&quot;,
            &quot;slot&quot;: 42862090
        },
        {
            &quot;keyHash&quot;: &quot;keyhash&quot;,
            &quot;type&quot;: &quot;sig&quot;
        }
    ]
}
</code></pre>
<p>address:</p>
<pre><code>hash     0        5000000 lovelace + TxOutDatumHashNone
</code></pre>
<p>calculate fee:</p>
<pre><code>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 
</code></pre>
<p>transaction:</p>
<pre><code>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+&quot;1 $(cat policy/nft/policy.id).head00&quot; --mint=&quot;1 $(cat policy/nft/policy.id).head00&quot; --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
</code></pre>
<p>sign transaction</p>
<pre><code>cardano-cli transaction sign  --tx-body-file keys/nfttx.raw  --signing-key-file keys/payment.skey --mainnet  --out-file keys/tx.signed
</code></pre>
<p>error:</p>
<pre><code>Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (ScriptWitnessNotValidatingUTXOW (fromList [ScriptHash &quot;keyhash&quot;])))])
</code></pre>
<p>EDIT: I get the same error even when submitting a transaction without the invalidation of the policy script part.</p>

CC BY-SA 4.0
2021-10-18T06:04:07.497Z
Please add add the commands that your are executing
raghu
CC BY-SA 4.0
2021-10-18T08:10:44.690Z
@raghu I think I forgot signing the transaction with my policy.skey. If you update your answer I'll accept it.
Bahamas
CC BY-SA 4.0
2021-10-27T03:36:24.943Z
I'm having the same problem. Did you find a solution?
cardadodev
CC BY-SA 4.0
2021-11-16T00:09:56.813Z
@cardadodev The transaction needs to be signed with the policy.skey and the payment.skey together.
Bahamas
<cardano-cli><cardano-node>
ScriptWitnessNotValidatingUTXOW error when submitting transaction
# ScriptWitnessNotValidatingUTXOW error when submitting transaction

(Asked by: username_0 on 2021-10-16)

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.

**Tags:** cardano-cli, cardano-node
> **Comments:**
> **username_1**: Please add add the commands that your are executing  
> **username_0**: @raghu I think I forgot signing the transaction with my policy.skey. If you update your answer I'll accept it.  
> **username_2**: I'm having the same problem. Did you find a solution?  
> **username_0**: @cardadodev The transaction needs to be signed with the policy.skey and the payment.skey together.  

---

## 2 answers

### Answer by username_1 on 2021-10-17. Score: 2 | Accepted answer

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.

> **Comments:**
> **username_0**: I just changed it for the question. I put the correct keyhash in the script.  
> **username_4**: @Bahamas so why did you accept this answer if it didn't help you?  

---

### Answer by username_3 on 2022-07-19. Score: 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.


---

