If you are interested in Ethereum and smart contract development but you aren't exactly an ace software developer, or maybe you have no coding knowledge at all, then you are in the right place. In this article, I briefly talk about my background and how I was able to go from no coding experience to creating my first decentralized application within a year.
I've been in the cyber and tech world for about eight years, but I've had little to no exposure to the software development side of things. I left my last cybersecurity job back in March, days before the world started freaking out about COVID, leaving me unemployed for months due to the lockdowns.
What better time, I thought, to finally pick up a coding language or two?
Smart Contracts
Picking a coding language, or languages I should say, was easy. I wanted to get into blockchain engineering and smart contract development. Why? Because for once in my life, I wanted to get ahead of the herd. I wanted to get ahead of something that is not only fascinating but revolutionary.
Not only that but smart contracts, along with decentralized oracles and blockchains, provide a layer of trust in agreements that is orders of magnitude higher than we have today.
When you combine the fact that agreements in some form or another power all global trade and commerce with the fact that trust is the most powerful economic force in the world, it seemed like a no-brainer for where I wanted to take my career next. Smart contracts will dominate, and there will be a serious need for blockchain engineers and developers.
Smart contract development on Ethereum primarily uses Javascript and Solidity. Javascript should need no introduction, but Solidity might. Solidity is an object-oriented, high-level language for implementing Ethereum smart contracts.
If you aren't entirely familiar with what a smart contract is, Investopedia's definition is:
A smart contract is a self-executing contract with the terms of the agreement between buyer and seller being directly written into lines of code.
What You Need To Know
When creating an application on Ethereum, you have to not only have knowledge of how to create a smart contract, but also how to create a front end, or a user-facing website. Together, these two pieces essentially combine to form a decentralized application.
I started with Solidity but quickly realized that it wasn’t the greatest programming language for a beginner to start with. Instead, I pivoted to something a little more well-known — Javascript.
Decentralized applications and smart contracts use Javascript pretty extensively for the front-end, testing, and connecting your smart contract to the web 3.0. Without having a reasonable foundation in Javascript, you won't get very far, so I recommend starting there.
While I was working on learning the fundamentals of Javascript, I also took a few courses here and there on HTML and CSS. I wasn’t aiming to become a pro front-end developer, I just wanted the basics down so that I could build out a website and plug it into a smart contract without the website looking like crap.
Once I started to feel somewhat comfortable with Javascript and HTML/CSS, I moved on to a front-end Javascript library called React. I chose React because it has a great community, and is one of the most popular front-end libraries when it comes to decentralized application development.
I'll have to warn you that although React is super cool, it's a bit of a beast to learn. Don't skimp on the fundamentals before moving on to frameworks or libraries.
Smart Contract Code
Without further ado, let's get into the smart contract code for my Ethereum application. Just as a warning, though - this is a high-level walk-through, so don't expect a detailed explanation of every little aspect of the code or the application.
Don't get too caught up in the details or what every little part does if you aren't familiar with Solidity. Just know that the code essentially takes in a string, or any combination of letters and numbers, stores it in an array, and writes it to the blockchain when the user hits the submit button on the website.
Along with the string, the application records whatever blockchain address you were using at the time. Scroll back up to see what the application looks like after recording a few messages if you need to.
The code above has two functions. The first function setMessage takes in a variable that allows you to change the message and then push the message into the savedMessages array. The second function getMessage simply just returns the strings that you saved in the array when it is called. And that's about as complex as it gets.
I originally wrote this smart contract on a free Solidity coding platform called Remix. Remix allows anyone to write smart contracts on their website, deploy them to a test blockchain, and interact with the functions to test them out. It's an awesome tool and I highly recommend you check it out.
Front-End
Moving on to the front-end, as I mentioned earlier, I used React for this project. The benefit of React is that it allows us to break up our application into what are called components which are separate pieces of Javascript and JSX code that make up the website.
In the React website that you can see at the beginning of this article, I used a CSS framework called Bootstrap for styling. It's yet another thing to learn but makes styling your website considerably easier. In the Navbar in the upper-right hand corner of the app, you can also see the blockchain address that I was connected to at the time.
It took a good amount of React code to put together my application, but I found it pretty cool to not only see how smart contracts "plug in" to front-end websites, but to actually make it happen myself. The React code essentially manages the user interactions with the website and calls certain functions within the smart contract, which in this app's case, recorded the strings to the blockchain and displayed them back to us on the website.
I'm not going to cover the front-end code or go into detail on everything you need to know for that, but if you wanted to at least look at the code, you can check out my Github repo.
Putting It All Together
I'm obviously skipping over a lot here, but there you have it - my first decentralized Ethereum application! I wish I could tell you that you only needed to know Solidity and Javascript to make this all happen (if that weren't a large enough effort in itself), but unfortunately, there is a lot more that you need to know.
To name a few - private blockchains like Ganache for testing out your application locally, testnets, mainnets, knowledge of the underlying Ethereum blockchain architecture and how smart contracts work behind the scenes, development frameworks such as Truffle or Hardhat, and blockchain wallets and gateways such as Metamask.
As you can see, there is basically a mountain of information that you need to know that goes into creating even the most basic Ethereum application. But don't let this scare you off! If it was easy, everyone would be doing it. And hopefully, if you are anything like me, this stuff excites you and you love to learn.
I estimated that over the course of one year, I probably put in on average 2-4 hours a day learning how to code as well as learning the surrounding blockchain development technologies. That equals anywhere from 600-1,200 hours to build a basic Ethereum application!
It hasn't exactly been smooth sailing or a nice straight linear path to get to this point, but it's important to realize that it's a marathon, not a sprint. You don't need to be a genius to learn any of this either. Consistency, passion, and a solid work ethic are all that it takes.
If you enjoyed this article and want to learn more, please stay tuned, as I have plans for much more content around Ethereum, Solidity, and smart contract development. This includes why I think blockchain engineering is a great career choice, the best learning resources that I've come across, and in-depth Solidity walkthroughs.