Due to the fact, that I am storing txId obtained from the user, before determining whether transaction has been ended or not, I want to make sure that the transaction hash, which will be stored in my database, has a correct format.

Is there any way to accomplish this task?

1 Answer 1


The transaction hash is the result of hashing the rlp-encoded transaction with keccak256() (many APIs erroneously call it sha3()). The hash produces 32 bytes data. When hex-encoded, that produces 64 hex characters (0-9, a-f, or A-F), plus usually an "0x" prefix. For example:

  • Thank you for your answer. I just used following regex: r"^(0x[A-Fa-f0-9]{64})$"
    – D Komo
    Oct 12, 2018 at 16:12

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.