<jupyter_start><jupyter_text>Bob has a problem Exceptionally DO NOT RUN this one! DO NOT delete output!! 06.9 Winter School on Smart Contracts <NAME> (<EMAIL>)2022-02-16* How to get rid of an annoying ASA  SetupSee notebook 04.1, the lines below will always automatically load functions in `algo_util.py`, the 5 accounts and the Purestake credentials<jupyter_code># Loading shared code and credentials
import sys, os

codepath = '..'+os.path.sep+'..'+os.path.sep+'sharedCode'
sys.path.append(codepath)
from algo_util import *
cred = load_credentials()

# Shortcuts to directly access the 3 main accounts
MyAlgo  = cred['MyAlgo']
Alice   = cred['Alice']
Bob     = cred['Bob']
Charlie = cred['Charlie']
Dina    = cred['Dina']
from algosdk import account, mnemonic
from algosdk.v2client import algod
from algosdk.future import transaction
from algosdk.future.transaction import PaymentTxn
from algosdk.future.transaction import AssetConfigTxn, AssetTransferTxn, AssetFreezeTxn
from algosdk.future.transaction import LogicSig

import algosdk.error
import json
import base64
import pandas as pd
from pyteal import *
# Initialize the algod client (Testnet or Mainnet)
algod_client = algod.AlgodClient(algod_token='', algod_address=cred['algod_test'], headers=cred['purestake_token'])
print(Alice['public'])
print(Bob['public'])
print(Charlie['public'])<jupyter_output>HITPAAJ4HKANMP6EUYASXDUTCL653T7QMNHJL5NODL6XEGBM4KBLDJ2D2E
O2SLRPK4I4SWUOCYGGKHHUCFJJF5ORHFL76YO43FYTB7HUO7AHDDNNR5YA
5GIOBOLZSQEHTNNXWRJ6RGNPGCKWYJYUZZKY6YXHJVKFZXRB2YLDFDVH64<jupyter_text>Bob has a problem* We cannot access the holdings of Bob in our nice function* Because Bob holds zero units of an ASA that has been deleted (the TEMP coin)* We want to find the culprit and get rid of it<jupyter_code># This produces the problem
Bob_holding=asset_holdings_df(algod_client, Bob['public'])<jupyter_output><empty_output><jupyter_text>Step 1: Identify the problematic ASA* It must be an ASA with zero holdings* And possibly missing information<jupyter_code>algod_client.account_info(Bob['public'])['assets']<jupyter_output><empty_output><jupyter_text>Step 2: Get rid of the problematic ASA* Send an `AssetTransferTxn` with the `close_assets_to` argument<jupyter_code># Step 1: prepare transaction
sp = algod_client.suggested_params()
amt = int(0)
asset_index = 70637093


txn = AssetTransferTxn(sender=Bob['public'], 
                       sp=sp, 
                       receiver=Bob['public'], 
                       amt=amt,
                       index=asset_index, 
                       close_assets_to=Bob['public']
                      )

# Step 2+3+4: sign and send and wait ...
stxn = txn.sign(Bob['private'])
txid = algod_client.send_transaction(stxn)
txinfo = wait_for_confirmation(algod_client, txid)<jupyter_output>Current round is  19813781.
Waiting for round 19813781 to finish.
Waiting for round 19813782 to finish.
Transaction TXS74NE3OUBF5KXNKRFHAEDNR7QJPOEPIUB4Z2WZNZFB5IBWSJNA confirmed in round 19813783.
{'fraction_non_alphanumeric': 0.0849214309595453, 'fraction_numerical': 0.034102306920762285, 'mean_word_length': 5.156378600823046, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '289999', 'license': 'MIT', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1005, 'n_words': 270, 'path': 'ClassMaterial/06 - Smart Signatures/06 code/06.9_WSC_Bob_has_a_problem.ipynb', 'repo_name': 'gruberpeter/smartcontractscourse', 'size': '3009'}