0

I am getting this error on transaction submission. ""transaction submit error ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (UtxoFailure (FromAlonzoUtxoFail (UtxosFailure (ValidationTagMismatch (IsValid True) (FailedUnexpectedly (PlutusFailure \"\\nThe 3 arg plutus script (PlutusScript PlutusV1 ScriptHash \\\"ae7b1ca9255aa4000270f38e5ee7d75b0af4955866123b5d794b54f0\\\") fails.\\nCekError An error has occurred: User error:\\nThe machine terminated because of an error, either from a built-in function or from an explicit use of 'error'.\\nThe protocol version is: ProtVer {pvMajor = 8, pvMinor = 0}\\nThe data is: I 0\\nThe redeemer is: Constr 0 []\\nThe context is:\\nPurpose: Spending (TxOutRef {txOutRefId = bac7a90f9efc79aa7af175d119bb55140423cea4f6b7c72f3141b96ccbc7e31c, txOutRefIdx = 0})\\nTxInfo:\\n TxId: 2af255afcb495512d1aa502ae7c985f97c1e66ad97328c8d8db9555936b9839b\\n Inputs: [ bac7a90f9efc79aa7af175d119bb55140423cea4f6b7c72f3141b96ccbc7e31c!0 -> - Value (Map [(,Map [(\\\"\\\",1000000)])]) addressed to\\n ScriptCredential: ae7b1ca9255aa4000270f38e5ee7d75b0af4955866123b5d794b54f0 (no staking credential)\\n , bac7a90f9efc79aa7af175d119bb55140423cea4f6b7c72f3141b96ccbc7e31c!1 -> - Value (Map [(,Map [(\\\"\\\",9993127795)]),(65b00f2037ae0e74172da23589a121a34861bfe51d4c436a21483cf5,Map [(\\\"myNFT2\\\",1)])]) addressed to\\n PubKeyCredential: d38f63fe3306e5f63e0e29691f50b0357e2f6d56ab18bfbd9a97bc2f (StakingHash PubKeyCredential: e53568cb1de2a784ad8c67d3273057c714472528dd27b09cc7687b26) ]\\n Outputs: [ - Value (Map [(,Map [(\\\"\\\",1000000)])]) addressed to\\n PubKeyCredential: d38f63fe3306e5f63e0e29691f50b0357e2f6d56ab18bfbd9a97bc2f (StakingHash PubKeyCredential: e53568cb1de2a784ad8c67d3273057c714472528dd27b09cc7687b26)\\n , - Value (Map [(,Map [(\\\"\\\",9992327046)]), -> Just cut the half error as it full of numbers and unreadable. My plutus script onchain has validation of we can unlock from the script by giving the redeemer 42. I am using mesh library to write the offchain code. My unlock function is here

  const utxos= await blockfrost.fetchAddressUTxOs (
    scriptAddress
  );
  const dataHash = resolveDataHash(datum);
  let utxo = utxos.find ((utxo:any)=>{
    return utxo.output.dataHash == dataHash;
  });

  return utxo;
}

async function unLock() {
  const assetUTXO = await _getAssetUTXO ({
    scriptAddress: scriptAddr,
    datum: 0,
  });

  const tx =  new Transaction ({initiator:wallet})
    .redeemValue({
      value: assetUTXO,
      script:fortyTwoScript,
      datum: 0 , 
      redeemer: 42,
})
    .sendValue(myAddress, assetUTXO)
    .setRequiredSigners([myAddress]);
      
    
  const unsignedTx = await tx.build();
  const signedTx = await wallet.signTx(unsignedTx, true);
  const txHash = await wallet.submitTx(signedTx);  
  console.log ("txHash of unlocking= ", txHash);
}

I was wondering that may be there is an issue in my script, but i have tested my script by locking and unlocking ADA with cardano cli. And it all went good. Please guide me with this error, I am stuck on this

1 Answer 1

0

Finally I got it and resolved. As I was locking lovelace in a script following the locking of assets. So i didnt made one change according to lovelace. So here is my modified function

  const assets = [
    {
      unit: "lovelace",
      quantity: 1000000,
    },
  ];  
  
  const assetUTXO = await _getAssetUTXO ({
    scriptAddress: myScriptAddress,
    asset: assets[0].unit,
    datum: 0,
  });
  console.log("asset UTXO = ", assetUTXO);
  
  const myRedeemer: Partial<Action> = {
    data: 42,
  };
  const tx =  new Transaction ({initiator:wallet})
    .redeemValue({
      value: assetUTXO,
      script:myScript,
      datum: 0 , 
      redeemer: myRedeemer,
})
    .sendValue(myAddress, assetUTXO)      
    
  const unsignedTx = await tx.build();
  const signedTx = await wallet.signTx(unsignedTx, true);
  const txHash = await wallet.submitTx(signedTx);  
  console.log ("txHash of unlocking= ", txHash);
} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.