0

This is my setup code.

const wallet = await BrowserWallet.enable('Nami');

// this script always succeeds regardless of the datum or redeemer
const script: PlutusScript = {
  code: '59079559079201...0122212200201',
  version: 'V2',
};

const scriptAddress = resolvePlutusScriptAddress(script, 0);

const myAddress = await wallet.getChangeAddress();

const myDatum: Data = {
  alternative: 0,
  fields: [42]
}

const myRedeemer = {
  data: {
    alternative: 0,
    fields: [21]
  }
}

I lock the funds in the script address using the function below and it works.

async function lock(ada: string) {
  
  const tx = new Transaction({ initiator: wallet })
    .sendLovelace(
      {
        address: scriptAddress,
        datum: {
          value: myDatum,
        }
      },
      ada + '000000'
    )

  try {
    const unsignedTx = await tx.build();
    const signedTx = await wallet.signTx(unsignedTx);
    const txHash = await wallet.submitTx(signedTx);
  } catch (err) {
    console.log(err.message);
  }
}

I have a helper function for getting asset utxos from the blockchain.

sync function _getAssetUtxo({ scriptAddress, datum, amount }) {

  try {

    //const koios = new KoiosProvider('preprod');
    //const utxos = await koios.fetchAddressUTxOs(scriptAddress);

    const blockfrostProvider = new BlockfrostProvider('preprod...Rkbm');
    const utxos = await blockfrostProvider.fetchAddressUTxOs(scriptAddress);

    const dataHash = resolveDataHash(datum);

    let utxo = utxos.find((utxo: UTxO) => {
      return utxo.output.dataHash == dataHash && utxo.output.amount[0].quantity == amount;
    });

    return utxo;

  } catch (err) {
    console.log(err);
  }

This is my function for unlocking the funds from the script address.

async function unlock(ada: string) {

  const assetUtxo = await _getAssetUtxo({
    scriptAddress: scriptAddress,
    datum: myDatum,
    amount: ada + '000000'
  });

  const tx = new Transaction({ initiator: wallet })
    .redeemValue({
      value: assetUtxo,
      script: script,
      datum: myDatum,
      redeemer: myRedeemer
    })
    .setRequiredSigners([myAddress])
    .sendValue(myAddress, assetUtxo)

  try {
    const unsignedTx = await tx.build();
    const signedTx = await wallet.signTx(unsignedTx, true);
    const txHash = await wallet.submitTx(signedTx);
  } catch (err) {
    console.log(err.message);
  }
}

But when I run the function above, I get the error bellow:

transaction submit error ShelleyTxValidationError ShelleyBasedEraBabbage 
(ApplyTxError [UtxowFailure (FromAlonzoUtxowFail 
(PPViewHashesDontMatch (SJust (SafeHash 
\"6ea33d2943315bf6179393f97af792376fd0c29851831b183c96a395db712337\")) 
(SJust (SafeHash 
\"ed2dc348e2070315e474c83981b40015d1dec8eaee9704735776e4d6147f7c41\"))))])

What am I doing wrong?

2 Answers 2

2

Mesh version 1.5.1 just got deployed to npm with the updated cost models for Plutus V2. Have a nice day and happy coding!!

1

The preprod env was upgraded this weekend and there were cost model updates for the upcoming release. Blockfrost wasn't in synch for with the latest cost model so you would get that error. This issue has been fixed and should be working now in preprod.

4
  • I waited a few days, updated Mesh to 1.5.0, tested with sending native assets and ADA only, tested with Blockfrost and Koios, tested with Nami and Eternl, and still getting the same error. Feb 14, 2023 at 21:17
  • 1
    Well, there is still (most likely) a mismatch between the network protocol parameter file used during transaction construction and what is then submitted to blockfrost. I am not too familiar with Mesh, but you need to find out what network parameter file is being used when you build the transaction. Are you using Demeter Run for your dev env. They should have everything setup and ready to go.
    – lley154
    Feb 15, 2023 at 0:34
  • Hi @lley154, the problem was due to the changes in the cost model, this changes was not broadcasted to the community. Or is it? If it is, how can I get subscribe to such update?
    – Jingles
    Feb 22, 2023 at 12:46
  • I started noticing a simliar issue on the Helios discord and I suspected it was a protocol parmeter mismtach (eg the cost mode), and then Gavin posted this to IOG techincal discord and one of the SPOs confirmed the change was done on preprod and Gavin confirmed the cost model had changed. Perhaps IOG can post something in IOG technical discord when a hard fork on preprod occurs, but I suspect there is a SPO discord channel that would broadcast this info as well. discord.com/channels/826816523368005654/826829805387120690/…
    – lley154
    Feb 25, 2023 at 0:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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