Accessing local state using PyTEAL

115 views Asked by At

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

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.

1

There are 1 answers

0
Web Zero On BEST ANSWER

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.