Convert app arg to Addr - General - Algorand
Convert app arg to Addr
post by ncoin on Mar 27, 2022
Lets say I have an app arg Txn[0].application_args[0]. I want to store local storage for an account address contained in the app arg. How can I convert Bytes() to Addr()?
post by fabrice on Mar 27, 2022
Internally, an address is just a 32-byte array.
So just ensure that the first argument is the 32 bytes of the address (without checksum and with base32 conversion).
See Overview - Algorand Developer Portal (where the actual 32-byte address is called “public key” in this document) and How to convert public key back to address in js sdk - #3 by fabrice
post by casper on Mar 28, 2022
I’m not sure the above will work because the address, if passed in as an arg, will need to be encoded and subsequently decoded in TEAL, which I’m not sure is possible yet. I would instead supply the address to the accounts array and store that in local/global state.
post by fabrice on Mar 28, 2022
You need to only use “decoded” 32-byte address as application arguments and state variables.
Everything in the chain itself uses this format.
The encoded addresses (like XFYAYSEGQIY2J3DCGGXCPXY5FGHSVKM3V4WCNYCLKDLHB7RYDBU233QB5M) are only for display.
The SDK must do all the encoding/decoding.