Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Accessing local state using PyTEAL

I’m having some trouble accessing the local state using PyTeal.

I’m trying to store a value in the local state of an account that has opted-in to the smart contract this way:

App.localPut(Int(0),Bytes("owner"), account_1)

, where account_1 is an

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Algorand address

and this transaction works fine.

Now, I’m trying to send a NoOp transaction from

account_1

, and passing 1 address in the accounts array – the account that sent the transaction above.

The issue:

is_owner = Txn.sender() == App.localGet(Int(1), Bytes("owner"))

is_owner always returns false.

Any suggestions on what I’m doing wrong? Thank you.

>Solution :

It sounds like you are not using the correct encoding of the address you’re storing.

Are you using the 32 byte public key (not the 58 byte key)?

Try using the decode_address function on the 58 byte key, and you will receive the 32 byte key. That should work.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading