Constructing the Future

Crypto Jam — With a Jar

Building a Cryptocurrency, Deploying it to a Testnet , and Interacting With It With a Custom GUI

Matt Stokes
Geek Culture

--

Cryptocurrencies are the bread and butter of the Blockchain industry — but what are they, and how do they work? Through my articles on Medium, I do my best to explain the nitty-gritty technical concepts that form the foundations of the modern-day blockchain space through a theoretical, simplified lens. However, some concepts deserve a more exhaustive and, indeed — more technical overview. As such, in this article, I decided not only to address cryptocurrencies from a more comprehensive, technical angle — but to do so by building my own cryptocurrency, deploying it to both a machine-native and Testnet blockchain, and finally building a GUI to interact with said cryptocurrency.

Check out my finished project here!

Lingo You Need to Know 🧠

  • ERC20 Token Standard: The standard token format that ensures every token (mostly in the form of cryptocurrencies in the case of the ERC20 Token Standard) that is released on the Ethereum blockchain is compatible with the various Dapps built to interact with it and other Ethereum based crypto projects.
  • Smart contract: this article.
  • Dapp: Decentralized Applications — basically any application that runs on the blockchain.
  • Consensus Mechanisms: Programs that ensure that the blockchain runs smoothly and the blockchain is not altered from its original path.

What Are Cryptocurrencies? At a Basic Level

Although Blockchain was ideated initially in the early 1990s, the first real, tangible implementation didn’t come around till 2008 — in the famous form of Satoshi Nakamoto’s Bitcoin.

Bitcoin made waves in the seas of world commerce and economies because of its unique Blockchain-bound principles. It was decentralized, immutable, and had real value thanks to the Cryptographic Proof System known as Proof of Work.

Proof of Work is a consensus mechanism that ensures Bitcoin and other Crypto projects maintain their significance by exchanging miner-created value (in this case, electricity and computational power) for validation on the Blockchain. There are a multitude of other validation mechanisms used in the blockchain industry today, but the two main ones you should understand are Proof of Work (as explained above) and Proof of Stake, which saves electricity by randomly selecting machines to mine new blocks from a pool of users who have staked crypto as collateral for the chance to mine.

It is through validation mechanisms that cryptocurrencies can exist and hold value online; before the Blockchain, someone could just infinitely copy a jpg to the extent where no one knew the JPG’s origin — which gets concerning when we discuss the notion of money on the internet. If you could infinitely copy your online money, there would be no way of verifying if your money was legitimate or not.

In summary, Cryptocurrencies are online currencies that hold real value thanks to their ability to tackle the famed internet copyright dilemma.

Overview of the Project

In order to dive deeper into the world of Cryptography and Blockchain than what can be afforded by online research, I decided to build my own cryptocurrency, Stoked Coin (STC), deploy it to both a local and Testnet Blockchain, and then create a Javascript powered GUI to interact with the smart contract. Here is the finished result:

This being one of my first Blockchain projects, progress was slow at first. I find that I often learn the best by hacking my way to a finished project, so I opted out of following any singular tutorial for my project and instead tried to organically apply the skills I have learned thus far to build out the project without too much reference to anything else. The exception to that rule is that I used an excellent Pixie.js tutorial from https://georgefrancis.dev/ to build out the front-end aesthetics in a Glassmorphism design language (George Francis is incredibly talented I suggest checking out his portfolio and previous work).

Brief Technical Insight

I built a basis of Blockchain knowledge and dev abilities before beginning the project, here are the sources I suggest.

Getting Started

After building my basis of knowledge, I jumped right into the project.

My first step was to build a model token smart contract to learn the basic requirements for a cryptocurrency; essentially, all cryptocurrencies have to satiate several parameters to be usable as cryptocurrencies. These parameters include a three-digit symbol, a name, a supply, a function to allow the tokens to be fractionalized (Solidity numbers won’t do this automatically), and an address to which the contract will send the initial supply of tokens. This is quite easy to build in Solidity, at which point you could deploy your contract to the Testnet, create a React.js UI to interact with it, and immediately begin exchanging tokens between accounts for fun.

However, although functional on the Testnet, this smart contract will not contain the necessary code for your new crypto to be usable on the Ethereum Mainnet to any large extent, which is where the ERC20 Standard comes into play. The ERC-20 standard ensures that all coins/tokens on the Ethereum Mainnet are compatible with the various Dapps end-users will want to use to interact with their tokens.

Build an ERC-20 Standard Token

Creating an ERC20 standard tokens smart contract is easily accomplished with the OpenZepplin ERC20 Preset, which you can pop into a file on Remix (an online Solidity editor with a built-in GUI to interact with ERC20 Tokens), edit a little bit and then deploy it to the blockchain. Once you have deployed your token to the Testnet, Remix will deliver the contract address to the built-in GUI, and you can proceed to look up your contract on Etherscan! Final step is to send the token supply to your wallet address which is most easily accomplished through Remix’s provided GUI.

The Fun Part

After you have built out your cryptocurrency, all that is left to do is to play around with it; send it to your friends on the Testnet, get them to send it to their friends, etc.

If you are using a wallet like Metamask, the function to send and receive crypto is already baked into its UI, but knowing how to build a UI to interact with a crypto project or DAPP is still a valuable skill so let’s do a quick overview of the basics. There are a ton of videos online that go through the specifics of building a UI to interact with a token and take you from 0–100, so I will quickly summarize.

Tech Stack and Quick Code Explanation

The first step is to figure out what development environment you will work in: I like hardhat because it is easy to use through the terminal, so let’s assume we are using that.

If your setup of the Hardhat environment is successful, you will launch into a quick start guide that funnels you into a sample project folder. The sample project is a small solidity program that, when connected with its App.js and deploy scripts, console.logs a preset text string every time you load the program. Fun but pretty useless. Delete the Greeter.sol file. Actually, because we have already launched the Token contract to the blockchain through Remix, we don’t need anything in our contracts folder.

delete that file 🙄

Build Your UI

Though there are a lot of housekeeping things you need to do to prepare your project for launch on the Testnet (or the Mainnet), the only other significant step in this project is building out the Javascript code to interact with the token contract.

In the App.js file, you need at least three main functions: An App function, a getBalance function and a sendCoins function.

  • In the App function, all you need to do is request the user’s Metamask account, and then create a variable out of the input of a text field to receive the address of the wallet you are sending your token to, as well as use the big number variable to set the unit size of your token equal to 1.0.
  • In the getBalance function, you read the token contract and identify it in the user’s Metamask wallet and then alert the user to their current balance.
  • Finally, the sendCoins function requests the user’s account, verifies that they are signing the contract, then takes the variables we created in the above to functions and sends the designated amount of crypto to the chosen address.

And the Crowd Goes Wild 🎉

Viola, you are now a crypto pro… not really; this was an incredibly surface-level explanation. My goal with this post was less to leave you with all the dev skills you will need to begin immediately building out blockchain projects and more to introduce you at a basic level to the tech stack and different terminologies you will need to start building in the blockchain. As well as explain on a technical level the complex on-chain systems we identify as cryptocurrencies.

Lets Review

  1. Cryptocurrencies contain blockchain-bound principles like decentralization, immutability and validation mechanisms, which precipitate into their ability unique ability to maintain value online.
  2. Validation mechanisms are systems that rely on different nodes on the network to pass transactions on the blockchain. The top two most popular of these validation mechanisms are Proof of Work and Proof of Stake.
  3. The act of building a cryptocurrency is rather simple, which is why it is essential to do your research when investing in cryptocurrencies. Some coins have legit teams working behind the scenes to continue building the value of their project and the community surrounding it, while other cryptos are constructed in the space of an hour in someone’s basement and have zero future outside the initial hype they manage to drum up.
  4. DAPPs built for the blockchain can be easily integrated into and interacted with in Web2 development environments if you have decent experience with Frontend languages like React.js and Javascript.

I hope you found as much value in reading about this project as I did in building and writing about it. I encourage you to look up some tutorials and attempt a project like this on your own as there is no better teacher than experience. Cheers!

--

--

Matt Stokes
Geek Culture

Hey! My name is Matt and I am a 17 yr/old innovator/entrepreneur, fascinated with the ever changing world of emerging technology!