How to convert public key back to address in js sdk

In command line:

$ base64 -d <<< ZXUc/psAtm6K6AOMpvytibbSa8H6WFc6O8XTp/rHuEE= | base32
MV2RZ7U3AC3G5CXIAOGKN7FNRG3NE26B7JMFOOR3YXJ2P6WHXBAQ====
MV2RZ7U3AC3G5CXIAOGKN7FNRG3NE26B7JMFOOR3YXJ2P6WHXBAQ====

Note that addresses have a checksum at the end, which the above does not have.

You can do the conversion with checksum with this python one-liner in console:

$ python3 -c 'import base64; import algosdk; print(algosdk.encoding.encode_address(base64.b64decode("ZXUc/psAtm6K6AOMpvytibbSa8H6WFc6O8XTp/rHuEE=")))'
MV2RZ7U3AC3G5CXIAOGKN7FNRG3NE26B7JMFOOR3YXJ2P6WHXBA4IGKRJ4

You need to install Python and the Python Algorand SDK beforehand:

$ python3 -m pip install py-algorand-sdk

JS SDK has similar functions.

1 Like