In this article, we will learn how we can use Algorand Python SDK to create a simple application.
Algorand
Algorand is a scalability-focused blockchain cryptocurrency technology. The Algorand platform supports smart contracts, and its consensus method is pure proof-of-stake (PPoS), which recruits network operators from the whole pool of ALGO currency holders, as well as a Byzantine agreement protocol. ALGO is the name of Algorand's native cryptocurrency. ALGO is a digital currency as well as a blockchain platform that is used to secure the Algorand blockchain and pay transaction fees for Algorand-based transactions. The Algorand platform is meant to handle a large number of transactions fast, much like a big payment processor such as Mastercard or Visa. Algorand is a direct competitor to Ethereum since it can host other cryptocurrencies and blockchain-based initiatives. Because it is an open-source blockchain, anybody may access and contribute to the platform's code.
Transactions handled over the Algorand network are completed in around four seconds.
The transaction charge is merely 1,000 microAlgos, or.001 Algos.
Because Algorand does not support forking, transactions are final once they are verified in a block. A throughput of 1,000 TPS translates to 1,000 completed transactions per second.
algod_address is the IP from which API endpoints can be accessed. 4001 is the default port. You can change it according to your need.
algod_token is an authentication token. 'aaaa.....' is the default value for the sandbox. If you are using a 3rd party tool, your token value will change.
Before the transaction is considered valid, it must be signed by a private key. Use the following code to sign the transaction.
signed_txn = unsigned_txn.sign(private_key)
The output will be
<algosdk.future.transaction.SignedTransaction object at 0x0000014EDA864550>
Submit the Transaction
The signed transaction can now be submitted to the network. wait_for_confirmation SDK Method is called after the transaction is submitted to wait until the transaction is broadcast to the Algorand blockchain and is confirmed.
txid = algod_client.send_transaction(signed_txn)
print("Signed transaction with txID: {}".format(txid))
The output will be
Signed transaction with txID: MA7MOY6BKOTUG6XBKLVFLWEHS45QNKGUYTFAHMBGN3TMKQQPVD3A
In the above code, we push our transaction to the testnet and print the transaction ID.
In the above code, we are waiting for the transaction to get submitted and verified from the testnet. I have kept it under try-except so as to catch any error or exception which may cause hindrance.
Printing the Final Details
After everything is done we need to print the below details:
Transaction Information
Decoded Note
Initial Balance
Amount Transferred
Transaction Fee
Final Balance
All of the above can be found using the following commands