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(

isValid = tx.is_valid();

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


1 Answer 1


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")


  • 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.
    Dec 11, 2021 at 11:32
  • 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: es.wikipedia.org/wiki/SHA-2#Funci%C3%B3n_hash . Dec 11, 2021 at 12:41

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.