Understanding Algorand as a Solidity Developer
I have been working on EVM chains for about two years and I recently started exploring Algorand. in this article, we will deep dive into the accounts architecture of the Algorand blockchain.
In Ethereum, we have a public-private key combination as an account
but in Algorand, accounts are different (they store data in themselves).
at the high level except for the address, the account contains 2 main parts Assets and Apps.
Let's first learn about assets
The Algorand protocol supports the creation of on-chain assets that benefit from the same security, compatibility, speed, and ease of use as the Algo. creating an asset and deploying a smart contract are two different things in Algorand more info
assets can be further divided into 2 types Created and Held.
Created: creating an asset is pretty simple you just set a few parameters and make an asset-create transaction.
once the transaction is successful you will get the asset id.
an asset id is just a unique number and it is needed to interact with the created asset.
held: the assets that you hold are stored in key-value pairs with asset id as key and asset balance as value.
opting into an asset
before receiving any asset you need to first opt in to that asset.
it is just a fancy way of saying you need to add an asset id(key) with balance 0 (value) into your account.
this means nobody can send you an asset that you are not opted into.
Apps
in Algorand smart contracts are called apps.
Algorand uses teal as its smart contract language. writing a smart contract in teal is a bit complex that’s why we use a python wrapper called Pyteal to make our job easy. Pyteal code is compiled and converted to teal and then deployed on the Algorand blockchain. once the app deployment is successful app id and app address is returned. this app id can be used to interact with the created app and the app address is used to receive algo/assets more info
basic info about the smart contract
- the teal smart contract contains an approval program and a clear program.
- there are only two data types supported by teal int and bytes.
- there are two types of storage available for the app
local state: data stored inside the specific user’s account
global states: data stored inside the app
while deploying you need to specify the state schema (the number of variables your app is using at each state).
Interacting with the App
same as assets you first need to make an opt-in transaction before interacting with the app.
all the local data is stored in the key-value format.
you can opt-out by sending close out transaction on that app and all the local data of that app will be deleted.
development tools
Closing thoughts
now you can go through the Algorand docs and hopefully, you will understand concepts a lot better.
there are a lot of things I didn’t cover and are worth taking a look
- Multisig wallet: without a smart contract
- atomic transfer: you can build an entire dex using this
- smart signature: you can set up a subscription
- updating App: upgradable smart contracts without proxies
- and much more...
Thank you for reading I hope this helped
feel free to drop questions/suggestions will be happy to help :)
helpful links
download the account architecture image
https://kctheservant.medium.com/first-attempt-on-algorand-bf56104c4b91
https://developer.algorand.org/solutions/whats-the-best-way-to-learn-about-algorand/