<p>Order of parameters is important!!!</p>
<p>From <code>cardano-cli transaction build --help</code>:</p>
<pre><code>Usage: cardano-cli transaction build                                                                                   
            [ --byron-era                                                                                              
            | --shelley-era                                                                                            
            | --allegra-era                                                                                            
            | --mary-era                                                                                               
            | --alonzo-era                                                                                             
            ]                                                                                                          
            [ --shelley-mode                                                                                           
            | --byron-mode [--epoch-slots NATURAL]                                                                     
            | --cardano-mode [--epoch-slots NATURAL]                                                                   
            ]                                                                                                          
            (--mainnet | --testnet-magic NATURAL)                                                                      
            [--script-valid | --script-invalid]                                                                        
            [--witness-override WORD]                                                                                  
            (--tx-in TX-IN                                                                                             
              [--tx-in-script-file FILE                                                                                
                [(--tx-in-datum-file FILE | --tx-in-datum-value JSON VALUE)                                            
                  ( --tx-in-redeemer-file FILE                                                                         
                  | --tx-in-redeemer-value JSON VALUE                                                                  
                  )]])                                                                                                 
            [--required-signer FILE]                                                                                   
            [--tx-in-collateral TX-IN]                                                                                 
            [--tx-out ADDRESS VALUE                                                                                    
              [ --tx-out-datum-hash HASH                                                                               
              | --tx-out-datum-hash-file FILE                                                                          
              | --tx-out-datum-hash-value JSON VALUE                                                                   
              | --tx-out-datum-embed-file FILE                                                                         
              | --tx-out-datum-embed-value JSON VALUE                                                                  
              ]]                                                                                                       
            --change-address ADDRESS                                                                                   
            [--mint VALUE                                                                                              
              (--mint-script-file FILE                                                                                 
                [--mint-redeemer-file FILE | --mint-redeemer-value JSON VALUE])]                                       
            [--invalid-before SLOT]                                                                                    
            [--invalid-hereafter SLOT]                                                                                 
            [--certificate-file CERTIFICATEFILE                                                                        
              [--certificate-script-file FILE                                                                          
                [ --certificate-redeemer-file FILE                                                                     
                | --certificate-redeemer-value JSON VALUE                                                              
                ]]]                                                                                                    
            [--withdrawal WITHDRAWAL                                                                                   
              [--withdrawal-script-file FILE                                                                           
                [ --withdrawal-redeemer-file FILE                                                                      
                | --withdrawal-redeemer-value JSON VALUE                                                               
                ]]]                                                                                                    
            [--json-metadata-no-schema | --json-metadata-detailed-schema]                                              
            [--auxiliary-script-file FILE]                                                                             
            [--metadata-json-file FILE | --metadata-cbor-file FILE]                                                    
            [--genesis FILE | --protocol-params-file FILE]                                                             
            [--update-proposal-file FILE]                                                                              
            --out-file FILE
</code></pre>
<p>Pay closer attention to this part:</p>
<pre><code>[--tx-out ADDRESS VALUE                                                                                    
              [ --tx-out-datum-hash HASH                                                                               
              | --tx-out-datum-hash-file FILE                                                                          
              | --tx-out-datum-hash-value JSON VALUE                                                                   
              | --tx-out-datum-embed-file FILE                                                                         
              | --tx-out-datum-embed-value JSON VALUE                                                                  
              ]] 
</code></pre>
<p>Notice how nested parameters are. I think you are basically attaching datum to <code>--tx-out $(cat 01.addr)+789600000</code> and not transaction to the smartcontract!</p>

CC BY-SA 4.0
2022-01-31T08:35:21.527Z
2022-01-31T08:35:21.527Z
KugisMugis
<p>I am trying to redeem the funds from the smart contract into the second wallet without running <code>cardano-node</code> (following the instructions from here: <a href="https://www.youtube.com/watch?v=ABtffZPoUqU&amp;list=PLNEK_Ejlx3x2zxcfoVGARFExzOHwXFCCL&amp;index=11" rel="nofollow noreferrer">https://www.youtube.com/watch?v=ABtffZPoUqU&amp;list=PLNEK_Ejlx3x2zxcfoVGARFExzOHwXFCCL&amp;index=11</a>) but I get the following error (bcc is blockfrost's cardano-cli is taken from here <a href="https://github.com/blockfrost/blockfrost-cardano-cli" rel="nofollow noreferrer">https://github.com/blockfrost/blockfrost-cardano-cli</a>):</p>
<pre><code>$ bcc transaction submit -f tx.signed -t
 ›   Error: Command failed: transaction submit error 
 ›   ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError 
 ›   [UtxowFailure (UnspendableUTxONoDatumHash (fromList [TxInCompact (TxId
 ›    {_unTxId = SafeHash 
 ›   \&quot;8583cadfd7a43be943b78b7756c9f02c7825f03dbc67d6dae24f6fb12080144e\&quot;})
 ›    0])),UtxowFailure (PPViewHashesDontMatch (SJust (SafeHash 
 ›   \&quot;ca6319c1203911911d372c25297cb9d6606b515a9157a5e9d0a5bcec642efd34\&quot;))
 ›    (SJust (SafeHash \&quot;a0e5ad883f81c0808f38cfc635e2ede5f760fcb4cb83f8bdcf
 ›   f0491b1f50b30f\&quot;)))])
</code></pre>
<p>After pretty-printing this error for a bit I found the two errors mentioned in the question.</p>
<p>Here are the commands I used:</p>
<pre><code># give.sh (these commands ran fine)

cardano-cli transaction build-raw \
    --alonzo-era \
    --tx-in c2e2ef139d709c1bb8a0e50efbc9100c41ca34f91a9027823afbfcb45acd6d55#1 \
    --tx-out $(cat vesting.addr)+200000000 \
    --tx-out $(cat 01.addr)+789600000 \
    --fee 200000 \
    --tx-out-datum-hash-file unit.json \
    --out-file tx.body

cardano-cli transaction sign \
    --tx-body-file tx.body \
    --signing-key-file 01.skey \
    --testnet-magic 1097911063 \
    --out-file tx.signed

bcc transaction submit -f tx.signed -t
</code></pre>
<p>then</p>
<pre><code># grab.sh

cardano-cli transaction build-raw \
    --alonzo-era \
    --tx-in 8583cadfd7a43be943b78b7756c9f02c7825f03dbc67d6dae24f6fb12080144e#0 \
    --tx-in-script-file vesting.plutus \
    --tx-in-datum-file unit.json \
    --tx-in-redeemer-file unit.json \
    --tx-in-execution-units &quot;(491845099,1197950)&quot; \
    --tx-in-collateral c2e2ef139d709c1bb8a0e50efbc9100c41ca34f91a9027823afbfcb45acd6d55#0 \
    --required-signer-hash 6cc0729360da2e3592e516f261161140ae96455c12861dec958a4d86 \
    --tx-out $(cat 02.addr)+199400000 \
    --fee 600000 \
    --protocol-params-file protocol.json \
    --out-file tx.body

cardano-cli transaction sign \
    --tx-body-file tx.body \
    --signing-key-file 02.skey \
    --testnet-magic 1097911063 \
    --out-file tx.signed

bcc transaction submit -f tx.signed -t
</code></pre>
<p>To fix <code>UnspendableUTxONoDatumHash</code> I tried to hash the unit.json file using <code>cardano-cli transaction hash-script-data --script-data-file unit.json &gt; datum.hash</code> but then the final command called this address <code>803a67b79578b8f24a15958a232b98aa2a40ec5e4d0e172e67336a235e51f328</code> as <code>UnspendableUTxONoDatumHash</code>.</p>
<p>To fix <code>PPViewHashesDontMatch</code> I tried searching for the hashes on the blockchain explorer but didn't find anything. In any case, I checked whether the beneficiary in Deploy.hs is set correctly but didn't find anything wrong there.</p>
<hr />
<h2>Edit #1</h2>
<p>after fixing order of options I changed the <code>build-raw</code> command in <code>give.sh</code> to</p>
<pre><code>cardano-cli transaction build-raw \
    --alonzo-era \
    --tx-in 079fa1b365b9a39a729968e3702f9a638f35cdcebdb1ea2ca5aeca4d32b20a0e#1 \
    --tx-out $(cat vesting.addr)+200000000 \
    --tx-out-datum-hash 923918e403bf43c34b4ef6b48eb2ee04babed17320d8d1b9ff9ad086e86f44ec \
    --tx-out $(cat 01.addr)+199200000 \
    --fee 200000 \
    --out-file tx.body
</code></pre>
<p>I get a different error</p>
<pre><code> ›   Error: Command failed: &quot;transaction submit error 
 ›   ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError 
 ›   [UtxowFailure (PPViewHashesDontMatch (SJust (SafeHash 
 ›   \&quot;ca6319c1203911911d372c25297cb9d6606b515a9157a5e9d0a5bcec642efd34\&quot;))
 ›    (SJust (SafeHash \&quot;a0e5ad883f81c0808f38cfc635e2ede5f760fcb4cb83f8bdcf
 ›   f0491b1f50b30f\&quot;))),UtxowFailure (WrappedShelleyEraFailure 
 ›   (UtxoFailure (UtxosFailure (ValidationTagMismatch (IsValid True) 
 ›   (FailedUnexpectedly [PlutusFailure \&quot;\\nThe 3 arg plutus script 
 ›   (PlutusScript PlutusV1 ScriptHash 
 ›   \\\&quot;4d8aa3f72ac815edd554d1f3ecdc708ba0d9e52cd161f3b3a5640042\\\&quot;) 
 ›   fails.\\nCekError An error has occurred:  User error:\\nThe provided 
 ›   Plutus code called 'error'.\\nThe data is: Constr 0 []
</code></pre>
<hr />
<h1>Edit 2</h1>
<p>Using the curl version of blockfrost transaction submit (<a href="https://docs.blockfrost.io/#tag/Cardano-Transactions/paths/%7E1tx%7E1submit/post" rel="nofollow noreferrer">https://docs.blockfrost.io/#tag/Cardano-Transactions/paths/~1tx~1submit/post</a>) I get some more info</p>
<pre><code>{
  &quot;error&quot;: &quot;Bad Request&quot;,
  &quot;message&quot;: &quot;\&quot;transaction submit error ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError 
    [UtxowFailure 
      (PPViewHashesDontMatch 
        (SJust 
          (SafeHash \\\&quot;ca6319c1203911911d372c25297cb9d6606b515a9157a5e9d0a5bcec642efd34\\\&quot;
          )
        ) 
        (SJust 
          (SafeHash \\\&quot;a0e5ad883f81c0808f38cfc635e2ede5f760fcb4cb83f8bdcff0491b1f50b30f\\\&quot;
          )
        )
      ),
    UtxowFailure 
      (WrappedShelleyEraFailure 
        (UtxoFailure 
          (UtxosFailure 
            (ValidationTagMismatch (IsValid True) 
              (FailedUnexpectedly 
                [PlutusFailure \\\&quot;\\\\nThe 3 arg plutus script 
                  (PlutusScript PlutusV1 ScriptHash \\\\\\\&quot;4d8aa3f72ac815edd554d1f3ecdc708ba0d9e52cd161f3b3a5640042\\\\\\\&quot;
                  ) fails.\\\\n
                  CekError An error has occurred:  User error:\\\\n
                  The provided Plutus code called 'error'.\\\\n
                  The data is: Constr 0 []\\\\n
                  The redeemer is: Constr 0 []\\\\n
                  The context is:\\\\n
                  Purpose: Spending (TxOutRef 
                    {txOutRefId = c3850544d66a0eef38326551c35807975c201f25787e8e9a379a306ee6f9c1f3, txOutRefIdx = 0
                    }
                  )\\\\n
                  TxInfo:\\\\n
                    TxId: d0aeeed88977e51047f7d455b5bac47f29c7ae70d9e5313bf504a35b3e56cd29\\\\n
                    Inputs: [ c3850544d66a0eef38326551c35807975c201f25787e8e9a379a306ee6f9c1f3!0 
                      -&gt; - Value (Map [(,Map [(\\\\\\\&quot;\\\\\\\&quot;,200000000)])]) addressed to\\\\n
                      ScriptCredential: 4d8aa3f72ac815edd554d1f3ecdc708ba0d9e52cd161f3b3a5640042 (no staking credential) ]\\\\n
                    Outputs: [ - Value (Map [(,Map [(\\\\\\\&quot;\\\\\\\&quot;,199400000)])]) addressed to\\\\n  &quot;,
  &quot;status_code&quot;: &quot;400&quot;
}
</code></pre>

CC BY-SA 4.0
2022-02-02T13:10:56.053Z
The `PPViewHashesDontMatch` error from Edit #2 is caused by protocol parameters file not having cost models field populated - this is a problem with `blockfrost-cardano-cli` not having access to cost models via Api resulting in script transactions failing.
sorki
<plutus-pioneer-program><cardano-cli><testnet><blockfrost>
PPViewHashesDontMatch and UnspendableUTxONoDatumHash error on redeeming funds from week03 example
# PPViewHashesDontMatch and UnspendableUTxONoDatumHash error on redeeming funds from week03 example

(Asked by: username_0 on 2022-01-30)

I am trying to redeem the funds from the smart contract into the second wallet without running cardano-node (following the instructions from here: https://www.youtube.com/watch?v=ABtffZPoUqU&list=PLNEK_Ejlx3x2zxcfoVGARFExzOHwXFCCL&index=11) but I get the following error (bcc is blockfrost's cardano-cli is taken from here https://github.com/blockfrost/blockfrost-cardano-cli):
$ bcc transaction submit -f tx.signed -t
 ›   Error: Command failed: transaction submit error 
 ›   ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError 
 ›   [UtxowFailure (UnspendableUTxONoDatumHash (fromList [TxInCompact (TxId
 ›    {_unTxId = SafeHash 
 ›   \"8583cadfd7a43be943b78b7756c9f02c7825f03dbc67d6dae24f6fb12080144e\"})
 ›    0])),UtxowFailure (PPViewHashesDontMatch (SJust (SafeHash 
 ›   \"ca6319c1203911911d372c25297cb9d6606b515a9157a5e9d0a5bcec642efd34\"))
 ›    (SJust (SafeHash \"a0e5ad883f81c0808f38cfc635e2ede5f760fcb4cb83f8bdcf
 ›   f0491b1f50b30f\")))])

After pretty-printing this error for a bit I found the two errors mentioned in the question.
Here are the commands I used:
# give.sh (these commands ran fine)

cardano-cli transaction build-raw \
    --alonzo-era \
    --tx-in c2e2ef139d709c1bb8a0e50efbc9100c41ca34f91a9027823afbfcb45acd6d55#1 \
    --tx-out $(cat vesting.addr)+200000000 \
    --tx-out $(cat 01.addr)+789600000 \
    --fee 200000 \
    --tx-out-datum-hash-file unit.json \
    --out-file tx.body

cardano-cli transaction sign \
    --tx-body-file tx.body \
    --signing-key-file 01.skey \
    --testnet-magic 1097911063 \
    --out-file tx.signed

bcc transaction submit -f tx.signed -t

then
# grab.sh

cardano-cli transaction build-raw \
    --alonzo-era \
    --tx-in 8583cadfd7a43be943b78b7756c9f02c7825f03dbc67d6dae24f6fb12080144e#0 \
    --tx-in-script-file vesting.plutus \
    --tx-in-datum-file unit.json \
    --tx-in-redeemer-file unit.json \
    --tx-in-execution-units "(491845099,1197950)" \
    --tx-in-collateral c2e2ef139d709c1bb8a0e50efbc9100c41ca34f91a9027823afbfcb45acd6d55#0 \
    --required-signer-hash 6cc0729360da2e3592e516f261161140ae96455c12861dec958a4d86 \
    --tx-out $(cat 02.addr)+199400000 \
    --fee 600000 \
    --protocol-params-file protocol.json \
    --out-file tx.body

cardano-cli transaction sign \
    --tx-body-file tx.body \
    --signing-key-file 02.skey \
    --testnet-magic 1097911063 \
    --out-file tx.signed

bcc transaction submit -f tx.signed -t

To fix UnspendableUTxONoDatumHash I tried to hash the unit.json file using cardano-cli transaction hash-script-data --script-data-file unit.json > datum.hash but then the final command called this address 803a67b79578b8f24a15958a232b98aa2a40ec5e4d0e172e67336a235e51f328 as UnspendableUTxONoDatumHash.
To fix PPViewHashesDontMatch I tried searching for the hashes on the blockchain explorer but didn't find anything. In any case, I checked whether the beneficiary in Deploy.hs is set correctly but didn't find anything wrong there.

Edit #1
after fixing order of options I changed the build-raw command in give.sh to
cardano-cli transaction build-raw \
    --alonzo-era \
    --tx-in 079fa1b365b9a39a729968e3702f9a638f35cdcebdb1ea2ca5aeca4d32b20a0e#1 \
    --tx-out $(cat vesting.addr)+200000000 \
    --tx-out-datum-hash 923918e403bf43c34b4ef6b48eb2ee04babed17320d8d1b9ff9ad086e86f44ec \
    --tx-out $(cat 01.addr)+199200000 \
    --fee 200000 \
    --out-file tx.body

I get a different error
 ›   Error: Command failed: "transaction submit error 
 ›   ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError 
 ›   [UtxowFailure (PPViewHashesDontMatch (SJust (SafeHash 
 ›   \"ca6319c1203911911d372c25297cb9d6606b515a9157a5e9d0a5bcec642efd34\"))
 ›    (SJust (SafeHash \"a0e5ad883f81c0808f38cfc635e2ede5f760fcb4cb83f8bdcf
 ›   f0491b1f50b30f\"))),UtxowFailure (WrappedShelleyEraFailure 
 ›   (UtxoFailure (UtxosFailure (ValidationTagMismatch (IsValid True) 
 ›   (FailedUnexpectedly [PlutusFailure \"\\nThe 3 arg plutus script 
 ›   (PlutusScript PlutusV1 ScriptHash 
 ›   \\\"4d8aa3f72ac815edd554d1f3ecdc708ba0d9e52cd161f3b3a5640042\\\") 
 ›   fails.\\nCekError An error has occurred:  User error:\\nThe provided 
 ›   Plutus code called 'error'.\\nThe data is: Constr 0 []


Edit 2
Using the curl version of blockfrost transaction submit (https://docs.blockfrost.io/#tag/Cardano-Transactions/paths/~1tx~1submit/post) I get some more info
{
  "error": "Bad Request",
  "message": "\"transaction submit error ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError 
    [UtxowFailure 
      (PPViewHashesDontMatch 
        (SJust 
          (SafeHash \\\"ca6319c1203911911d372c25297cb9d6606b515a9157a5e9d0a5bcec642efd34\\\"
          )
        ) 
        (SJust 
          (SafeHash \\\"a0e5ad883f81c0808f38cfc635e2ede5f760fcb4cb83f8bdcff0491b1f50b30f\\\"
          )
        )
      ),
    UtxowFailure 
      (WrappedShelleyEraFailure 
        (UtxoFailure 
          (UtxosFailure 
            (ValidationTagMismatch (IsValid True) 
              (FailedUnexpectedly 
                [PlutusFailure \\\"\\\\nThe 3 arg plutus script 
                  (PlutusScript PlutusV1 ScriptHash \\\\\\\"4d8aa3f72ac815edd554d1f3ecdc708ba0d9e52cd161f3b3a5640042\\\\\\\"
                  ) fails.\\\\n
                  CekError An error has occurred:  User error:\\\\n
                  The provided Plutus code called 'error'.\\\\n
                  The data is: Constr 0 []\\\\n
                  The redeemer is: Constr 0 []\\\\n
                  The context is:\\\\n
                  Purpose: Spending (TxOutRef 
                    {txOutRefId = c3850544d66a0eef38326551c35807975c201f25787e8e9a379a306ee6f9c1f3, txOutRefIdx = 0
                    }
                  )\\\\n
                  TxInfo:\\\\n
                    TxId: d0aeeed88977e51047f7d455b5bac47f29c7ae70d9e5313bf504a35b3e56cd29\\\\n
                    Inputs: [ c3850544d66a0eef38326551c35807975c201f25787e8e9a379a306ee6f9c1f3!0 
                      -> - Value (Map [(,Map [(\\\\\\\"\\\\\\\",200000000)])]) addressed to\\\\n
                      ScriptCredential: 4d8aa3f72ac815edd554d1f3ecdc708ba0d9e52cd161f3b3a5640042 (no staking credential) ]\\\\n
                    Outputs: [ - Value (Map [(,Map [(\\\\\\\"\\\\\\\",199400000)])]) addressed to\\\\n  ",
  "status_code": "400"
}

**Tags:** plutus-pioneer-program, cardano-cli, testnet, blockfrost
> **Comments:**
> **username_1**: The `PPViewHashesDontMatch` error from Edit #2 is caused by protocol parameters file not having cost models field populated - this is a problem with `blockfrost-cardano-cli` not having access to cost models via Api resulting in script transactions failing.  

---

## 1 answers

### Answer by username_2 on 2022-01-31. Score: 3

Order of parameters is important!!!
From cardano-cli transaction build --help:
Usage: cardano-cli transaction build                                                                                   
            [ --byron-era                                                                                              
            | --shelley-era                                                                                            
            | --allegra-era                                                                                            
            | --mary-era                                                                                               
            | --alonzo-era                                                                                             
            ]                                                                                                          
            [ --shelley-mode                                                                                           
            | --byron-mode [--epoch-slots NATURAL]                                                                     
            | --cardano-mode [--epoch-slots NATURAL]                                                                   
            ]                                                                                                          
            (--mainnet | --testnet-magic NATURAL)                                                                      
            [--script-valid | --script-invalid]                                                                        
            [--witness-override WORD]                                                                                  
            (--tx-in TX-IN                                                                                             
              [--tx-in-script-file FILE                                                                                
                [(--tx-in-datum-file FILE | --tx-in-datum-value JSON VALUE)                                            
                  ( --tx-in-redeemer-file FILE                                                                         
                  | --tx-in-redeemer-value JSON VALUE                                                                  
                  )]])                                                                                                 
            [--required-signer FILE]                                                                                   
            [--tx-in-collateral TX-IN]                                                                                 
            [--tx-out ADDRESS VALUE                                                                                    
              [ --tx-out-datum-hash HASH                                                                               
              | --tx-out-datum-hash-file FILE                                                                          
              | --tx-out-datum-hash-value JSON VALUE                                                                   
              | --tx-out-datum-embed-file FILE                                                                         
              | --tx-out-datum-embed-value JSON VALUE                                                                  
              ]]                                                                                                       
            --change-address ADDRESS                                                                                   
            [--mint VALUE                                                                                              
              (--mint-script-file FILE                                                                                 
                [--mint-redeemer-file FILE | --mint-redeemer-value JSON VALUE])]                                       
            [--invalid-before SLOT]                                                                                    
            [--invalid-hereafter SLOT]                                                                                 
            [--certificate-file CERTIFICATEFILE                                                                        
              [--certificate-script-file FILE                                                                          
                [ --certificate-redeemer-file FILE                                                                     
                | --certificate-redeemer-value JSON VALUE                                                              
                ]]]                                                                                                    
            [--withdrawal WITHDRAWAL                                                                                   
              [--withdrawal-script-file FILE                                                                           
                [ --withdrawal-redeemer-file FILE                                                                      
                | --withdrawal-redeemer-value JSON VALUE                                                               
                ]]]                                                                                                    
            [--json-metadata-no-schema | --json-metadata-detailed-schema]                                              
            [--auxiliary-script-file FILE]                                                                             
            [--metadata-json-file FILE | --metadata-cbor-file FILE]                                                    
            [--genesis FILE | --protocol-params-file FILE]                                                             
            [--update-proposal-file FILE]                                                                              
            --out-file FILE

Pay closer attention to this part:
[--tx-out ADDRESS VALUE                                                                                    
              [ --tx-out-datum-hash HASH                                                                               
              | --tx-out-datum-hash-file FILE                                                                          
              | --tx-out-datum-hash-value JSON VALUE                                                                   
              | --tx-out-datum-embed-file FILE                                                                         
              | --tx-out-datum-embed-value JSON VALUE                                                                  
              ]] 

Notice how nested parameters are. I think you are basically attaching datum to --tx-out $(cat 01.addr)+789600000 and not transaction to the smartcontract!


---

