<p>It is impossible to go from hash to the object that generated the hash. But you can de-serialize the byte representation of a transaction for using in the WASM methods on it,with this:</p>
<pre><code> const transactionObjet = WASM.Transaction.from_bytes(
Buffer.from(CBORHextransaction, &quot;hex&quot;)
</code></pre>
<p>);</p>

CC BY-SA 4.0
2021-12-11T11:32:23.263Z
Yes. That is what I was trying. But... what you call 'transactionHexString' is the same as the Transaction Hash? I guess not. I am getting transaction hashes, so, do i need to convert the hash to a hexString to be able to use it with the code above? Does emurgo serlization library has any method to do that?
Jose M.R.
CC BY-SA 4.0
2021-12-11T12:41:56.230Z
No it is not the txHash... it is the CBOR hex-encoded whole transaction, you can not get the objet that generated the hash from the hash at a theoretical level .Thats the key concept of crypto. You can read more about the subject here: https://es.wikipedia.org/wiki/SHA-2#Funci%C3%B3n_hash .
Alicia Basilio
CC BY-SA 4.0
2021-12-10T23:29:22.740Z
2021-12-11T12:43:06.660Z
2021-12-11T12:43:06.660Z
Alicia Basilio
<p>I want to validate Transactions to make sure they are actual Cardano txs with correct length, format etc.</p>
<p>I see that Transaction object in emurgo serialization library has an 'is_valid()' method that I guess returns if tx is valid or not.</p>
<p>The point is that I have the txHash (random example: 5ea96bdc7ab5e13c68838482eedf7b97382310f450bade5589bf500fed894ed7).</p>
<p>I am trying to convert from the txHash to the Transaction object, but library returns an error:</p>
<p>&quot;Deserialization failed in Transaction because: Invalid cbor: not the right type, expected <code>Array' byte received </code>Bytes'&quot;</p>
<p>This is what i am trying:</p>
<pre><code>var txBytes = Buffer.from(txHash, 'hex');

const tx = WASM.Transaction.from_bytes(
    txBytes
);

isValid = tx.is_valid();
</code></pre>
<p>Any idea how can i get Transaction object from a txHash?</p>
<p>Thanks</p>

<transaction><cbor><hash>
Validate Transaction with serialization lib from a Tx Hash
# Validate Transaction with serialization lib from a Tx Hash

(Asked by: username_0 on 2021-12-10)

I want to validate Transactions to make sure they are actual Cardano txs with correct length, format etc.
I see that Transaction object in emurgo serialization library has an 'is_valid()' method that I guess returns if tx is valid or not.
The point is that I have the txHash (random example: 5ea96bdc7ab5e13c68838482eedf7b97382310f450bade5589bf500fed894ed7).
I am trying to convert from the txHash to the Transaction object, but library returns an error:
"Deserialization failed in Transaction because: Invalid cbor: not the right type, expected Array' byte received Bytes'"
This is what i am trying:
var txBytes = Buffer.from(txHash, 'hex');

const tx = WASM.Transaction.from_bytes(
    txBytes
);

isValid = tx.is_valid();

Any idea how can i get Transaction object from a txHash?
Thanks

**Tags:** transaction, cbor, hash

---

## 1 answers

### Answer by username_1 on 2021-12-10. Score: 0

It is impossible to go from hash to the object that generated the hash. But you can de-serialize the byte representation of a transaction for using in the WASM methods on it,with this:
 const transactionObjet = WASM.Transaction.from_bytes(
Buffer.from(CBORHextransaction, "hex")

);

> **Comments:**
> **username_0**: Yes. That is what I was trying. But... what you call 'transactionHexString' is the same as the Transaction Hash? I guess not. I am getting transaction hashes, so, do i need to convert the hash to a hexString to be able to use it with the code above? Does emurgo serlization library has any method to do that?  
> **username_1**: No it is not the txHash... it is the CBOR hex-encoded whole transaction, you can not get the objet that generated the hash from the hash at a theoretical level .Thats the key concept of crypto. You can read more about the subject here: https://es.wikipedia.org/wiki/SHA-2#Funci%C3%B3n_hash .  

---

