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"
}
PPViewHashesDontMatch
error from Edit #2 is caused by protocol parameters file not having cost models field populated - this is a problem withblockfrost-cardano-cli
not having access to cost models via Api resulting in script transactions failing.