Quick question… Held local state on a no longer needed stateful smart contract. Used CLI’s goal to clear it. Local state has disappeared, great. Minimum balance still enforced though. Any idea why?
Welcome to Algorand!
If you cleared out all the contracts and assets, the minimum balance should be 0.1 Algo.
What minimum balance do you get? How did you check it?
Can you reproduce the issue on TestNet (on a fresh address) and give the address?
Thank you! I have resolved the issue, it looks like “goal app clearstate” was not sufficient and had to call also closeout. Clearstate cleared the state, it worked, but left the address opted-in, which still required increased minimum balance. Thanks.
I’ve checked on sandbox and with the engineers, goal app clear
should actually reduce the minimum balance.
Most likely the clear transaction did not go through.
If you still see the issue, can you give a minimum working example exhibiting the issue?
Here is a demonstration that goal app clear
reduces the min balance, with sandbox (GitHub - algorand/sandbox: Algorand node sandbox).
Setup of sandbox, accounts, and app
$ ./sandbox up
...
$ ./sandbox goal account new app_creator
Created new account with address 5P64OIO4ZYMKL5H2Q6JLNVBJXLXPRYM4FHXSS5FJY2V2KJRYMA2BMZ4TDM
$ ./sandbox goal account new app_optin
Created new account with address CBQYS3JJ6HR7STTVGIRXBMPMMXLQWIDSMRS7HJKTDKIDB6CT7B5IMEDTNA
$ ./sandbox goal account list
[offline] app_optin CBQYS3JJ6HR7STTVGIRXBMPMMXLQWIDSMRS7HJKTDKIDB6CT7B5IMEDTNA 0 microAlgos
[online] INIFNRAJ7FH7R7ZDCUPMB4SKW6EKLPSIA2H2C2MCEREBWZUJCLHQIJSHY4 INIFNRAJ7FH7R7ZDCUPMB4SKW6EKLPSIA2H2C2MCEREBWZUJCLHQIJSHY4 4000000000000000 microAlgos
[offline] L2ATKIYX4BNAVNM5UHPFNMSXY2PAUO47PMKMOKWF4USUOHD7AFJKFHBREI L2ATKIYX4BNAVNM5UHPFNMSXY2PAUO47PMKMOKWF4USUOHD7AFJKFHBREI 1000000000000000 microAlgos
[offline] QSQINTB3MQNQFKY52626OVZVPTBWC74SEERFOCKGUM3OEY26KZIRQIMTEM QSQINTB3MQNQFKY52626OVZVPTBWC74SEERFOCKGUM3OEY26KZIRQIMTEM 4000000000000000 microAlgos
[offline] app_creator 5P64OIO4ZYMKL5H2Q6JLNVBJXLXPRYM4FHXSS5FJY2V2KJRYMA2BMZ4TDM 0 microAlgos *Default
$ ./sandbox goal clerk send --from INIFNRAJ7FH7R7ZDCUPMB4SKW6EKLPSIA2H2C2MCEREBWZUJCLHQIJSHY4 --to app_creator --amount 10000000
...
$ ./sandbox goal clerk send --from INIFNRAJ7FH7R7ZDCUPMB4SKW6EKLPSIA2H2C2MCEREBWZUJCLHQIJSHY4 --to app_optin --amount 10000000
...
$ export ADDR_CREATOR="5P64OIO4ZYMKL5H2Q6JLNVBJXLXPRYM4FHXSS5FJY2V2KJRYMA2BMZ4TDM"
export TEAL_APPROVAL_PROG="int1.teal"
export TEAL_CLEAR_PROG="int1.teal"
export GLOBAL_BYTESLICES=0
export GLOBAL_INTS=1
export LOCAL_BYTESLICES=0
export LOCAL_INTS=1
$ ./sandbox goal app create --creator $ADDR_CREATOR \
--approval-prog "$TEAL_APPROVAL_PROG" \
--clear-prog "$TEAL_CLEAR_PROG" \
--global-byteslices $GLOBAL_BYTESLICES \
--global-ints $GLOBAL_INTS \
--local-byteslices $LOCAL_BYTESLICES \
--local-ints $LOCAL_INTS
...
Created app with app index 3
$ ./sandbox goal app optin --app-id 3 --from CBQYS3JJ6HR7STTVGIRXBMPMMXLQWIDSMRS7HJKTDKIDB6CT7B5IMEDTNA
Now account app_creator=5P64OIO4ZYMKL5H2Q6JLNVBJXLXPRYM4FHXSS5FJY2V2KJRYMA2BMZ4TDM
created the app ID 3 and app_optin=CBQYS3JJ6HR7STTVGIRXBMPMMXLQWIDSMRS7HJKTDKIDB6CT7B5IMEDTNA
opted it to it.
Checking the min balance of CBQYS3JJ6HR7STTVGIRXBMPMMXLQWIDSMRS7HJKTDKIDB6CT7B5IMEDTNA
The simplest way is to make a transaction so that the resulting balance will go below the min balance. Then the error will display the min balance
$ ./sandbox goal clerk send --from CBQYS3JJ6HR7STTVGIRXBMPMMXLQWIDSMRS7HJKTDKIDB6CT7B5IMEDTNA --to INIFNRAJ7FH7R7ZDCUPMB4SKW6EKLPSIA2H2C2MCEREBWZUJCLHQIJSHY4 --amount 9899999
Couldn't broadcast tx with algod: HTTP 400 Bad Request: TransactionPool.Remember: transaction EIOJVVAWMQB4LDGF44F7P5562GJP5CCYR7CUECJEOK6Y6VPT4RUQ: account CBQYS3JJ6HR7STTVGIRXBMPMMXLQWIDSMRS7HJKTDKIDB6CT7B5IMEDTNA balance 98030 below min 228500 (0 assets)
The minimum balance became 228,500 microAlgos.
Clear state of CBQYS3JJ6HR7STTVGIRXBMPMMXLQWIDSMRS7HJKTDKIDB6CT7B5IMEDTNA
$ ./sandbox goal app clear --app-id 3 --from CBQYS3JJ6HR7STTVGIRXBMPMMXLQWIDSMRS7HJKTDKIDB6CT7B5IMEDTNA
Checking the min balance of CBQYS3JJ6HR7STTVGIRXBMPMMXLQWIDSMRS7HJKTDKIDB6CT7B5IMEDTNA
$ ./sandbox goal clerk send --from CBQYS3JJ6HR7STTVGIRXBMPMMXLQWIDSMRS7HJKTDKIDB6CT7B5IMEDTNA --to INIFNRAJ7FH7R7ZDCUPMB4SKW6EKLPSIA2H2C2MCEREBWZUJCLHQIJSHY4 --amount 9899999
Couldn't broadcast tx with algod: HTTP 400 Bad Request: TransactionPool.Remember: transaction TZJV4CYGWWN5AO4SSIRKUAVDFDC3R26FT4RYHRH6Z6S4TEIKLTPQ: account CBQYS3JJ6HR7STTVGIRXBMPMMXLQWIDSMRS7HJKTDKIDB6CT7B5IMEDTNA balance 97030 below min 100000 (0 assets)
The minimum balance is back to 100,000 microAlgos.
Fabrice, this is great!
I can confirm I can run all the steps you have listed and the behavior is the same as what you are getting: the clear changes the minimum balance required back to the usual 0.1 algos.
Also, I can’t reproduce the original issue anymore, so I think you might be right, something must have gone wrong with the clear somehow. If this ever happens again, I will note all the steps down, but I suspect I must have done something wrong!
Thanks!