Solidity Arrays (Fixed-Sized and Dynamic-Sized)

Arrays are a data structure that organize information in a list. In the language of Solidity, arrays all store the same type of information, and can be thought of as an X-Y table, where the X column is an auto-incrementing number, and the Y column is the user’s input. Here’s are a few arrays: The … Read more

Solidity If Else Statements (Ternary Operator)

Conditionals, also known as “if/else statements”, in Solidity are very simple to write and allow a developer to create a contract that behaves in different ways based on the current state of the blockchain. Here is a simple if/else smart contract: In this contract, we have 3 functions that accept an unsigned number, and return … Read more

Pure Functions in Solidity

The Pure modifier is added to a function in Solidity when a function doesn’t read to or write to the blockchain. This is used in cases where the developer wants to create a function to perform computation only. This not only lowers the total size of the contract, it also reduces vulnerabilities by restricting access … Read more

Solidity For Loop

For Loops create the ability to loop through a certain section of code multiple times, creating a simple way to automate certain code. They should be used lightly in Solidity, since they are very computationally heavy and usually require a lot of gas to run. Here is a very simple “for loop” written in solidity … Read more

Solidity Counter

This contract is a simple counter written in Solidity. The variable “count” starts at 0 by default, and the functions “increase” and “decrease” change the number respectively. Here is the output when we click the “increase” function twice: Let’s go through line by line: The first 2 lines of code are the SPDX License Identifier, … Read more

Solidity Immutable

The immutable keyword is used for variables that act very similar to constants, however they can be initialized with a constructor. After these immutable variables are created and changed during deployment, they can never be changed again. The purpose of this is to prevent vulnerabilities from editing an important variable, while allowing the developer to … Read more

Solidity Constants

Constants in Solidity are variables that cannot be modifier once they are deployed. The purpose of this is to prevent vulnerabilities from changing important variables that shouldn’t ever change in the contract’s life. Using constants also saves on the gas costs associated with deploying and using a contract. Please note that Solidity will not let … Read more

Solidity Hello World

Welcome to this tutorial on how to write your first “hello world” program in Solidity! Solidity is a programming language that is used to create smart contracts on the Ethereum blockchain. In this tutorial, we will go through the steps to create a simple Solidity program that will print “hello world” to the screen. By … Read more

Pragma Solidity Version

Pragma Solidity is a shortened way of saying “Pragmatic Information for Solidity” and it is usually followed by the version of Solidity you wish to use for the following contract. Here is how you will see it often used in a smart contract: This is usually the second line of code in a Solidity smart … Read more

Solidity SPDX-License-Identifier Line

The SPDX-License-Identifier is a special line of code that put inside a comment to specific the licensing rights of a code. In Solidity, the License Identifier is used to let other developers know how they can use someone else’s code. In some cases, it is free to use, reproduce, or copy… however in other cases, … Read more