Spaces:
Runtime error
Runtime error
File size: 1,975 Bytes
0bda635 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | import os
from algosdk import account, mnemonic
from algosdk.v2client import algod
from algosdk.transaction import AssetConfigTxn, wait_for_confirmation
from dotenv import load_dotenv
load_dotenv()
# Configure Algorand Client (Testnet)
# You can use a free API key from AlgoNode or PureStake, or a local node
ALGOD_ADDRESS = "https://testnet-api.algonode.cloud"
ALGOD_TOKEN = ""
def create_admc_token():
# Helper function to get the private key and address
mnemonic_phrase = os.getenv("ALGORAND_MNEMONIC")
if not mnemonic_phrase:
print("Please set ALGORAND_MNEMONIC in .env")
return
private_key = mnemonic.to_private_key(mnemonic_phrase)
sender_address = account.address_from_private_key(private_key)
print(f"Sender Address: {sender_address}")
# Initialize Algod Client
algod_client = algod.AlgodClient(ALGOD_TOKEN, ALGOD_ADDRESS)
# Asset Creation Transaction
params = algod_client.suggested_params()
txn = AssetConfigTxn(
sender=sender_address,
sp=params,
total=1_000_000_000, # 1 billion tokens
decimals=6,
default_frozen=False,
unit_name="ADMC",
asset_name="AdMarket Coin",
manager=sender_address,
reserve=sender_address,
freeze=sender_address,
clawback=sender_address,
url="https://rift.video", # Placeholder URL
)
# Sign transaction
signed_txn = txn.sign(private_key)
# Send transaction
txid = algod_client.send_transaction(signed_txn)
print(f"Transaction sent with ID: {txid}")
# Wait for confirmation
confirmed_txn = wait_for_confirmation(algod_client, txid, 4)
print(f"Result confirmed in round: {confirmed_txn['confirmed-round']}")
asset_id = confirmed_txn["asset-index"]
print(f"Created Asset ID: {asset_id}")
return asset_id
if __name__ == "__main__":
create_admc_token()
|