algorandfoundation / docs

MIT License
112 stars 284 forks source link

Error in stateful_smart_contracts.py #543

Closed ChrisBagge closed 3 years ago

ChrisBagge commented 3 years ago

Hi,

I get the following error on line 253

client.send_transactions([signed_txn])

algosdk.error.AlgodHTTPError: {"message":"TransactionPool.Remember: transaction GES6YAYHYATCBQLLW6T6V3GPLCV3IJFHW22DELJ2PJDPD4M4VKMQ: logic eval error: cannot fetch key, [sender] has not opted in to app 8"}

not sure how to opt in as the creator

Thanks, Chris

ChrisBagge commented 3 years ago

Hi,

I pulled out the approval_program and clear_program and tried to use the goal command. Here is the command followed by the error. This is in the sandbox env using the local blockchain

./sandbox goal app create --creator [address] --global-byteslices 0 --global-ints 1 --local-byteslices 1 --local-ints 1 --approval-prog approval_program.teal --clear-prog clear_program.teal Couldn't broadcast tx with algod: HTTP 400 Bad Request: TransactionPool.Remember: transaction HSXVUY6ICENQBKTC6SMDRWP3K3GLRSQHCS4EYXCVHJHAZYU3T7HQ: logic eval error: cannot fetch key, [address] has not opted in to app 1

Could someone let me know what I am missing?

Thank you, Chris

barnjamin commented 3 years ago

Do you have a link to the exact page you're using for this?

For the first one, in goal you'd just send an opt-in txn with the creator as the sender https://developer.algorand.org/docs/reference/cli/goal/app/optin/

For the second one, I'm not sure I've seen that on a create before, are you running the sandbox in dev mode?

ChrisBagge commented 3 years ago

I started with the code in this repository stateful_smart_contracts.py.

After I received the error from my first comment I copied the teal out of the python script and created two files and pieced together the call to app create

I tried the optin, but it is a little like the chicken and the egg, as I can't optin to an app that doesn't exist but I can't create the app since I haven't opted in.

I was running the sandbox in default mode with the private network. I just tried switching to testnet to see if that was the issue but now I get this error when running ./sandbox start testnet

Reading package lists... E: Release file for http://deb.debian.org/debian/dists/buster-updates/InRelease is not valid yet (invalid for another 11h 46min 5s). Updates for this repository will not be applied. ERROR: Service 'algod' failed to build : The command '/bin/sh -c apt-get update && apt-get install -y apt-utils curl git git-core bsdmainutils python3' returned a non-zero code: 100

thank you

barnjamin commented 3 years ago

I'd use the local ones, that is the config options that dont have net at the end.

Also, are you using an address different than the one in the example? it appears to be hardcoded to expect a very specific address. https://github.com/algorand/docs/blob/staging/examples/smart_contracts/v2/python/stateful_smart_contracts.py#L61

ChrisBagge commented 3 years ago

That was it!. Thank you for your help