How to Learn Solidity for Beginners
How-to Guides

How to Learn Solidity for Beginners

2 года назад

CoinMarketCap looks at Solidity — the programming language that Ethereum’s smart contracts and DApps are built with, and then explore the CryptoZombies game that teaches beginners Solidity.

How to Learn Solidity for Beginners

Содержание

What Is Solidity?

Solidity is the programming language that allowed Ethereum to expand blockchain technology beyond Bitcoin-style, peer-to-peer cryptocurrencies to become what one of its creators calls “one computer for the entire planet.”

It was proposed in 2014 by Dr. Gavin Wood, who worked with Vitalik Buterin to develop Ethereum. Solidity is the language of the self-executing smart contracts at the heart of the No. 2 blockchain. Seeing as decentralized apps — DApps — are essentially very complex smart contracts, Solidity is the language that everything from decentralized finance (DeFi) platforms to crypto games and supply chain management tools are built upon. 
Basically, anything that runs in the Ethereum Virtual Machine — the isolated computation engine of Ethereum in which all smart contracts are created, run and executed — can be, and largely is, built using Solidity. 

Join us in showcasing the cryptocurrency revolution, one newsletter at a time. Subscribe now to get daily news and market updates right to your inbox, along with our millions of other subscribers (that’s right, millions love us!) — what are you waiting for?

Pros of Solidity

Solidity has a number of strengths that helped build Ethereum into a juggernaut. For one thing, it was designed to be fairly simple to use by anyone with a basic knowledge of programming languages such as Javascript or C++.

For another, its smart contracts are built on a blockchain, so they cannot be altered or deleted. That means that Ethereum is a very secure way to do what it was designed to do — transfer anything of value, using either the native Ether tokens or the compatible but white-labeled ERC-20 tokens to pay for those transactions. 

Limitations of Solidity

That last one is a double-edged sword, however, as it means that any Solidity smart contract must be flawlessly written. As crypto design experts like to say: “Code is law.”

Mistakes cannot be fixed, transactions cannot be reversed, and exploits can only be fixed by updating the Ethereum code — which requires participation of individual nodes that is not always forthcoming, at least not swiftly. 

That was a problem with the 2016 DAO hack that drained $60 million in 2016 using an EVM vulnerability called re-entrancy — one of a number of known exploits — just as it was a problem with the Aug. 27, 2021 hack that caused a fork in the Ethereum blockchain. In both cases, the exploit was known and a fix had been released when it was exploited.
In July, the largest U.S. cryptocurrency exchange, Coinbase, released a tool named Solidify, which is used to detect and classify smart contract risks, an automated audit. As the tool’s name suggests, its goal is to improve Solidity smart contracts by finding potential flaws — something Coinbase does in its rigorous but time-consuming review of protocols whose tokens it is considering listing.

How Much Time Does it Take to Learn Solidity?

Solidity is what’s called a high-level, object-oriented programming (OOP) language developed for and primarily used by the Ethereum blockchain. OOPs allow developers to build programs using prebuilt snippets of code.

Solidity was designed to be particularly user-friendly to anyone with a basic familiarity with other, more mainstream coding languages including C++, Java, JavaScript and Python. This means that people with experience in the general programming concepts and aforementioned coding languages would take a shorter time to learn Solidity. This could take anywhere from one to six month.

However, if you have no idea how programming works — and your only knowledge is that of a shadowy super coder — then the second half of this article might be for you. There are numerous courses suited for complete beginners to pick up the basics of Solidity, even without a programming background.

How Much do Solidity Developers Make?

But first, why would you invest hours of your precious time learning how to code in Solidity, instead of checking prices of the next big meme token on CoinMarketCap?
According to cryptocurrencyjobs.co, the average base salary for a Solidity developer ranges from $125,000 to $145,000. Given the explosive growth of the crypto sector as a whole, and demand for crypto jobs rising, you can expect Solidity developers to be increasingly sought after.

Convinced yet? With that, let's dive into learning Solidity with CryptoZombies.

How to Learn Solidity for Beginners with CryptoZombies

One of the best ways to learn Solidity is with CryptoZombies — a free, interactive coding school used by more than 400,000 students to learn how to build Blockchain DApps by creating a simple video game.

There are two curriculums: Basic to intermediate smart contract design, and advanced Solidity, which covers testing and deploying DApps like your zombie game, and building oracles that bring trusted outside data that smart contracts can rely on to determine when to execute.

Basic Lesson: Creating Your Crypto Zombies

The basic lesson plan begins with building your zombie factory — creating a database of individual zombies on the blockchain, a method of creating new ones, and a numerical “DNA” function that controls each zombie’s appearance — and that of other creatures they infect. That is to say, making the characters.

There are six lessons, each with 11 to 15 steps covering different Solidity design concepts. These have both a very clear, simply written explanation of what you’re doing and why you’re doing it, and coding fields that lead you through creating the code to build the smart contract sections that the game is made up of. This is where you need some coding familiarity, but it largely boils down to understanding the terminology and basic concepts — those code snippets are used, and each chapter has a “check answer” button that gives the right answer if you get it wrong.

For example, this involves creating structs — giving the zombie a name and DNA string — making the database of zombies public, and making use of that DNA information.

Advanced Solidity Concepts on CryptoZombies

The second curriculum set covers creating a way for zombies to multiply by feeding on and infecting other lifeforms — adding and defining the game dynamics. Zombie snacks can be humans built in the game, but the lesson plan creates a way to infect CryptoKitties — well, using their DNA information to create new zombies without actually damaging the pricy NFT avatars. Which boils down to learning how to make your smart contract interact with an outside contract. 

Among other things this includes making zombies ownable — giving one user special privileges — using mappings and addresses. Then it moves on to creating the CryptoKitties interface, and determining how the genes extracted from them create zombies with new traits — like tails — to go along with the eye color and shape, bright shades of skin, and clothing design.

More lessons come after that, covering issues ranging from making CryptoZombies ownable, paying the Ethereum gas transaction fees, and keeping zombies secure.

Advanced Lesson: Creating NFTs of Zombies

Those are followed by a battle system; using ERC-721 standard to create non-fungible tokens — NFTs — that hold a unique zombie as well as “outsourcing” the need to create an auction system that allows users to buy, sell, and trade zombies; and building a front-end user interface including everything from MetaMask wallet interaction to managing transactions.

The advanced lessons cover testing your smart contracts for errors, deploying your smart contracts, and building oracles. There are a couple of places where some JavaScript is needed in addition to Solidity.

Further Lessons 

After that, the “Beyond Ethereum” curriculum cover non-Ethereum blockchains, including the Diem (formerly Libra) stablecoin, Ethereum-based Binance Smart Chain, and using zero-knowledge proofs — zkSync — providing security for token transfers, among other things.

And then you have a zombie game that helped you learn to build blockchain DApps and smart contracts — a good thing at a time when many blockchain companies are stymied by a “massive supply shortage” of developers who understand blockchain.
This article contains links to third-party websites or other content for information purposes only (“Third-Party Sites”). The Third-Party Sites are not under the control of CoinMarketCap, and CoinMarketCap is not responsible for the content of any Third-Party Site, including without limitation any link contained in a Third-Party Site, or any changes or updates to a Third-Party Site. CoinMarketCap is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement, approval or recommendation by CoinMarketCap of the site or any association with its operators. This article is intended to be used and must be used for informational purposes only. It is important to do your own research and analysis before making any material decisions related to any of the products or services described. This article is not intended as, and shall not be construed as, financial advice. The views and opinions expressed in this article are the author’s [company’s] own and do not necessarily reflect those of CoinMarketCap.
4 people liked this article