0

Bytea (hex) is format of PSQL. It is used by many explorers/dapps/apps to store ethereum address. how to convert this format to Python String?

By default it is read as a memory view.

More on Bytea: https://www.postgresql.org/docs/9.0/datatype-binary.html

0

Step 1: Convert bytes to python bytes format

Step 2 : convert bytes to hex format

Step 3 (optional) : append 0x to the hex format

address = bytes(bytea_from_psql)
hex_address = address.hex()
full_address = "0x" + hex_address

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.