Interpreting encoded variables in application info

I’m trying to verify the state of an application by inspecting the response of the application_info method call from the Python client. However, I’m not sure how to decode the variable values of type ‘bytes’, e.g.,

{'key': 'RVNDUk9XX0FERFJFU1M=', 'value': {'bytes': 'mnO9s9KHfnO8ZezwfKnlCjX2w/cUSO8+OuB4iL1kqV0=', 'type': 1, 'uint': 0}

Any help would be much appreciated.

The keys and values are base64 encoded, eg b64decode(RVNDUk9XX0FERFJFU1M=) == ESCROW_ADDRESS

The value in this case corresponds to an account address but I’m not able to fully recover the original address.

>>> bytes_str = 'mnO9s9KHfnO8ZezwfKnlCjX2w/cUSO8+OuB4iL1kqV0='
>>> bytes_decoded = base64.b64decode(bytes_str)
>>> base64.b32encode(bytes_decoded)
b'TJZ33M6SQ57HHPDF5TYHZKPFBI27NQ7XCREO6PR24B4IRPLEVFOQ===='

The original address is TJZ33M6SQ57HHPDF5TYHZKPFBI27NQ7XCREO6PR24B4IRPLEVFO7KOB2SM so I’m not sure why the decoded value differs in the last few characters.

hm, not sure why that’d happen. I guess I’d start by checking to make sure it doesn’t get truncated somehow on the way in?

Usual way of displaying addresses contain a checksum.

However, internally the blockchain removes this checksum for efficiency reasons.

See Overview - Algorand Developer Portal that also contains Python code to convert one representation to the other.

For the sake of completeness:

$ python3 -c "import base64, sys, algosdk; [print(base64.b32encode(algosdk.encoding.decode_address(line.strip())).decode()) for line in sys.stdin if line.strip()]" <<< TJZ33M6SQ57HHPDF5TYHZKPFBI27NQ7XCREO6PR24B4IRPLEVFO7KOB2SM
TJZ33M6SQ57HHPDF5TYHZKPFBI27NQ7XCREO6PR24B4IRPLEVFOQ====
1 Like