<p>I'm pretty sure this is a known bug which the devs are aiming to fix in the next hard fork. You can see the discussion here: <a href="https://github.com/Emurgo/cardano-serialization-lib/issues/227" rel="nofollow noreferrer">https://github.com/Emurgo/cardano-serialization-lib/issues/227</a></p>
<p>Does your transaction work when you submit it? If it doesn't, you should get a relevant error related to the datum which you can use to fix your transaction body.</p>

CC BY-SA 4.0
2021-11-02T04:44:56.020Z
2021-11-02T04:44:56.020Z
Blake Brown
<p>I am having trouble using cardano-serialization-lib. I am trying to calculate the datum hash from bytes using this library:</p>
<pre><code>var myBytes = Buffer.from(
    'b1566319045054327346e0043eed1af00eec2a63d9536f65087ca1c8'
  );
  const dtHash = hash_plutus_data(PlutusData.new_bytes(myBytes));
</code></pre>
<p>which gives me <code>a4c44696aa4ed831f3a1c0b86e407a8c092cf680e61ed23f0e47a15b73d59c79</code>
but when I tried to do it through cli with <code>cardano-cli transaction hash-script-data --script-data-file $datumFile</code>
where <code>datumFile</code> is</p>
<pre><code>{
    &quot;bytes&quot;: &quot;b1566319045054327346e0043eed1af00eec2a63d9536f65087ca1&quot;
}
</code></pre>
<p>I got <code>edc92947d6f09957c3fe31c10478e6eeee7fdaec1e2cc7439633325cd9bcf13f</code> instead</p>

CC BY-SA 4.0
2021-10-26T00:17:42.163Z
Did you manage to solve this?
martin
<cardano-cli>
datum hash of bytes is different between cardano-serialization-lib and cardano-cli
# datum hash of bytes is different between cardano-serialization-lib and cardano-cli

(Asked by: username_0 on 2021-09-22)

I am having trouble using cardano-serialization-lib. I am trying to calculate the datum hash from bytes using this library:
var myBytes = Buffer.from(
    'b1566319045054327346e0043eed1af00eec2a63d9536f65087ca1c8'
  );
  const dtHash = hash_plutus_data(PlutusData.new_bytes(myBytes));

which gives me a4c44696aa4ed831f3a1c0b86e407a8c092cf680e61ed23f0e47a15b73d59c79
but when I tried to do it through cli with cardano-cli transaction hash-script-data --script-data-file $datumFile
where datumFile is
{
    "bytes": "b1566319045054327346e0043eed1af00eec2a63d9536f65087ca1"
}

I got edc92947d6f09957c3fe31c10478e6eeee7fdaec1e2cc7439633325cd9bcf13f instead

**Tags:** cardano-cli
> **Comments:**
> **username_1**: Did you manage to solve this?  

---

## 1 answers

### Answer by username_2 on 2021-11-02. Score: 1

I'm pretty sure this is a known bug which the devs are aiming to fix in the next hard fork. You can see the discussion here: <https://github.com/Emurgo/cardano-serialization-lib/issues/227>

Does your transaction work when you submit it? If it doesn't, you should get a relevant error related to the datum which you can use to fix your transaction body.


---

