user609: 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?

user1118: 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.

user2511: 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!!

609: <p>This is my setup code.</p>
<pre><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]
  }
}
</code></pre>
<p>I lock the funds in the script address using the function below and it works.</p>
<pre><code>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);
  }
}
</code></pre>
<p>I have a helper function for getting asset utxos from the blockchain.</p>
<pre><code>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) =&gt; {
      return utxo.output.dataHash == dataHash &amp;&amp; utxo.output.amount[0].quantity == amount;
    });

    return utxo;

  } catch (err) {
    console.log(err);
  }
</code></pre>
<p>This is my function for unlocking the funds from the script address.</p>
<pre><code>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);
  }
}
</code></pre>
<p>But when I run the function above, I get the error bellow:</p>
<pre><code>transaction submit error ShelleyTxValidationError ShelleyBasedEraBabbage 
(ApplyTxError [UtxowFailure (FromAlonzoUtxowFail 
(PPViewHashesDontMatch (SJust (SafeHash 
\&quot;6ea33d2943315bf6179393f97af792376fd0c29851831b183c96a395db712337\&quot;)) 
(SJust (SafeHash 
\&quot;ed2dc348e2070315e474c83981b40015d1dec8eaee9704735776e4d6147f7c41\&quot;))))])
</code></pre>
<p>What am I doing wrong?</p>
 1118: <p>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.</p>
 2511: <p>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!!</p>
