I am running the simple vesting script from PPP for the first time with Lucid and I continuosly get an error which doesn't give me much to understand what could realistically be the source of.
the validator goes:
data MisteryDatum = MisteryDatum
{ beneficiary1 :: PubKeyHash
, beneficiary2 :: PubKeyHash
, deadline :: POSIXTime
}
unstableMakeIsData ''MisteryDatum
{-# INLINABLE mkMisteryValidator #-}
mkMisteryValidator :: MisteryDatum -> () -> ScriptContext -> Bool
mkMisteryValidator dat () ctx =
traceIfFalse "Benificiary1 did not sign or to late" checkCondition1 ||
traceIfFalse "Benificiary2 did not sign or is to early" checkCondition2
where
txInfo :: TxInfo
txInfo = scriptContextTxInfo ctx
txValidRange :: POSIXTimeRange
txValidRange = txInfoValidRange txInfo
checkCondition1 :: Bool
checkCondition1 = txSignedBy txInfo (beneficiary1 dat) &&
contains (to (deadline dat)) txValidRange
checkCondition2 :: Bool
checkCondition2 = txSignedBy txInfo (beneficiary2 dat) &&
contains (from (1 + deadline dat)) txValidRange
while the Lucid function that causes the error is:
async function claimVestedFunds(): Promise<TxHash> {
const dtm: Datum = Data.to<VestingDatum>(datum,VestingDatum);
const utxoAtScript: UTxO[] = await lucid.utxosAt(vestingAddress);
const ourUTxO: UTxO[] = utxoAtScript.filter((utxo) => utxo.datum == dtm);
if (ourUTxO && ourUTxO.length > 0) {
console.log(ourUTxO)
const tx = await lucid
.newTx()
.collectFrom(ourUTxO, Data.void())
.addSignerKey(beneficiaryPKH)
.attachSpendingValidator(vestingScript)
.validFrom(Date.now())
.complete();
const signedTx = await tx.sign().complete();
const txHash = await signedTx.submit();
return txHash
}
else return "No UTxO's found that can be claimed"
}
I checked date and beneficiary many times and they are correct, the only problem could be that I am using the same address public key for both benificiary1 and benificiary2. But that shouldn't be a problem right?
Anyway the function above shows the right UTxO
[
{
txHash: "a1d743f6a6c795dff9a5691ee25f1831485dd59f57476d6d9260691aaf65c3e6",
outputIndex: 0,
assets: { lovelace: 8700000n },
address: "addr_test1wznyv36t3a2rzfs4q6mvyu7nqlr4dxjwkmykkskafg54yzs735734",
datumHash: undefined,
datum: "d8799f581ccecc6981a300d41fac6ae169c569a297c2837b1d8988762034ba4a65581ccecc6981a300d41fac6ae169c569a2...",
scriptRef: null
}
]
At this point something in the validation fails before the transaction is even sent and I receive the followign error:
error: Uncaught (in promise) "Redeemer (Spend, 0): end of input bytes"
I don't understand what could cause it as everything seem right and the error isn't articulated enough to give me precise indications, but what seem to cause that error is the line .collectFrom(ourUTxO, Data.void())
which seem fine to me as the UTxO is the right UTxO and the redeemer has to be void.