Deutsch한국어日本語中文EspañolFrançaisՀայերենNederlandsРусскийItalianoPortuguêsTürkçePortfolio TrackerSwapCryptocurrenciesPricingIntegrationsNewsEarnBlogNFTWidgetsDeFi Portfolio TrackerOpen API24h ReportPress KitAPI Docs

Build your own coin on Algorand

6y ago
bullish:

6

bearish:

1

Algorand 2.0 and the Algorand Standard Asset have been released. It’s now time to implement EvanCoin 2.0.

Several coins. Some of the coins are colored silver, some are colored gold.

I previously talked about how to implement your own token on top of Algorand using layer two processing and the Algorand transaction’s note field. With the release of Algorand 2.0 and the Algorand Standard Asset, implementing your own token is now preposterously easy.

How easy? Well, the code I used to issue my own asset is 84 lines of golang, and much of that is comments and error handling. The pseudocode looks something like this:

Let’s go through the real thing and see what’s happening.

On lines 1 and 2 of the gist, we give credit to PureStake for their example — credit is important! Lines 4 and 5 start to set up arguments for building the algodClient , used to communicate to the network. For more on this I recommend the Algorand Developer Docs or the PureStake Examples. For this demonstration we’ll be connecting to a PureStake node, rather than our own node.

At the end, you can see a mnemonic and the corresponding public address. You could do something smarter here like using kmd or environment variables or passed-in arguments to handle keys, but instead in this example we’ll take the easier but less-advised route of hardcoded keys and addresses.

We’ll skip discussion of lines 23–45 or so of the main demonstration file. In summary, at the start of main() there is some setup, things like constructing the algodClient and querying the latest information from the network. One important step there is converting the mnemonic backup phrase to a private key, used later for signing and authorizing the transaction.

Once that’s all squared away, we can build our asset creation transaction:

Let’s go argument by argument and discuss. The total issuance of the coin is 1000000, that is, I declare there to be one million EvanCoin units. Then, I declare that the number of decimals to use for accounting is 0, or in other words, there is no notion of sats or wei or any subdivision; a 1 in a transaction should be displayed as 1 evancoin. If I had supplied decimals = 6, then that would be a hint to GUIs that we are really issuing “one million millionths of an EvanCoin”, and a 1 in a transaction should be displayed as .000001 evancoin.

Accounts in EvanCoin are defaulted to un-frozen, I don’t need to do any whitelisting before anyone can transact, they just need to opt in. Themanager is the address in charge of the asset, so I set it to my address. I don’t want there to be a notion of an EvanCoin reserve, so I set the reserve address to "" . This is just a fun demo coin for playing, so I give myself the privilege to freeze other addresses or clawback other people’s coins, not that I plan to do so. Plus, I could always permanently turn off these features later by reconfiguring the asset.

I’ll name the asset EvanCoin, and its units are evancoin. Instead of a link to a whitepaper or something, let’s just link to my GitHub, and let’s skip any fancy metadata hash commitments today.

That’s it! This transaction tx fully defines a brand new asset on the Algorand blockchain. We were particularly verbose about it for the sake of clarity, and it still only took ten lines of code. Let’s sign and send the transaction:

Success! The transaction can now be found on the Algorand MainNet. And, because I used the same private key and public key for this demo as I use in my Algorand Wallet, I can see the asset instantly:

A cropped screenshot of the Algorand mobile wallet (Android) showing 34.999279 Algos and 1,000,000 EvanCoin.

That’s truly it! Make the transaction, sign it, post it, and the asset now exists. Go forth now and let’s make some assets!

Resources

For more information please visit:


Build your own coin on Algorand was originally published in Algorand on Medium, where people are continuing the conversation by highlighting and responding to this story.

6y ago
bullish:

6

bearish:

1

Manage all your crypto, NFT and DeFi from one place

Securely connect the portfolio you’re using to start.