Getting AssetID and private keys

We are following a Python tutorial on how to transfer an asset. One of the requirements is

The AssetID of an Asset and the corresponding manager address and private key or mnemonic phrase.

How do we create these on testnet to start testing? We just starting with Algorand ecosystem.

1 Like

Here is a related tutorial on creating the asset in Python: https://developer.algorand.org/tutorials/create-asset-python/

Here are the related docs: https://developer.algorand.org/docs/features/asa/#creating-an-asset (these are linked to in the tutorial)

1 Like

This will create new ASA, do you know how to get list of ASSET IDā€™s created or owned by address ?

You can use the account_info method to retrieve all account information including assets created by the account. The assets created lives under "thisassettotal" in the account info json.

from algosdk import algod

# set up client using your credentials
algod_client = algod.AlgodClient("<algod_token>", "<algod_address>")

# retrieve account info
account_info = algod_client.account_info("<ADDRESS>")

# retrieve all assets created by this account
assets_created = account_info.get("thisassettotal")

# this returns a dictionary keyed by the asset ID. Asset IDs are ordered - the higher the ID the more recently it was created - so if you want the latest created asset, pick the max ID. 
last_created_asset = max([int(id) for id in assets_created.keys()])

# get asset info for latest created asset
asset_info = assets_created.get(str(last_created_asset))
print(asset_info)

Iā€™ve added a note to add this to the docs as well.

1 Like

thanks.
iā€™m getting this error from rest API when i try to create asset.
{ā€œmessageā€: ā€œMissing required request parameters: [Content-Type]ā€}

what might the reason ?

Seems like you may be missing the content type when you submit the transaction.

In Python

algod_client.send_transaction(signed_txn, headers={'content-type': 'application/x-binary'})

Or if youā€™re using curl:

curl -i -X POST \
   -H "X-Algo-API-Token:<algod-token> \
   -H "Content-Type:application/x-binary" \
   -T "signed-txn-file" \
 'http://<algod-address>:<algod-port>/v1/transactions'

More info here: https://developer.algorand.org/docs/build-apps/hello_world/#submit-the-transaction

1 Like

This worked.
Thanks a lot. i wasted 2 hours for this.
but why is this not documented and i donā€™t even see this in tutorials.
Again thanks for the help

The documentation link that you sent above has typo error for ā€œapplicationā€.
please get it fixed.