Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paul attah #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions algokit-utils-py
Submodule algokit-utils-py added at 816b54
85 changes: 85 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -1 +1,86 @@
from algokit_utils.beta.algorand_client import (
AlgorandClient,
AssetCreateParams,
AssetOptInParams,
AssetTransferParams,
PayParams,
)

# Client to connect to localnet
algorand = AlgorandClient.default_local_net()

# Import dispenser from KMD
dispenser = algorand.account.dispenser()
#print("Dispenser Address:", dispenser.address)

creator = algorand.account.random()
#print("Creator Address:", creator.address)
#print(algorand.account.get_information(creator.address))

# Fund creator account
algorand.send.payment(
PayParams(
sender=dispenser.address,
receiver=creator.address,
amount=10_000_000 # 10 algos
)
)

#print(algorand.account.get_information(creator.address))

sent_txn = algorand.send.asset_create(
AssetCreateParams(
sender=creator.address,
total=100,
asset_name="Edu4Teen",
unit_name="E4T",
)
)

asset_id=sent_txn["confirmation"]["asset-index"]
print("Asset ID", asset_id)

receiver_acct = algorand.account.random()

# Fund receiver_acct account
algorand.send.payment(
PayParams(
sender=dispenser.address,
receiver=receiver_acct.address,
amount=10_000_000 # 10 algos
)
)

print(algorand.account.get_information(receiver_acct.address))

# create a group txn
group_txn = algorand.new_group()

group_txn.add_asset_opt_in(
AssetOptInParams(
sender=receiver_acct.address,
asset_id=asset_id
)
)

group_txn.add_payment(
PayParams(
sender=receiver_acct.address,
receiver=creator.address,
amount=1_000_000 # 1 algo
)
)

group_txn.add_asset_transfer(
AssetTransferParams(
sender=creator.address,
receiver=receiver_acct.address,
asset_id=asset_id,
amount=10
)
)

group_txn.execute()

print("Receiver Account Asset Balance:", algorand.account.get_information(receiver_acct.address)['assets'][0]['amount'])
print("Creator Account Asset Balance:", algorand.account.get_information(creator.address)['assets'][0]['amount'])
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[tool.poetry]
name = "codespace-algorand"
version = "0.1.0"
description = ""
authors = ["Paul Attah <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.12"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"