Blockchain Development: Key Concepts

Sayna Parsi
4 min readNov 23, 2020

--

Pretty much how I felt while looking for blockchain development content. Illustration by Shel Silverstein’s Where the Sidewalk Ends.

I started this weekend with one goal: start developing with blockchain. The hello-world version of a new application in blockchain seemed to be deploying a smart contract so that’s what I started with. Some tutorials worked, but in the end, I didn’t feel like I had learned how things worked or I didn’t feel like I accomplished something meaningful. Other tutorials totally didn’t work and returned errors without a trace on the internet — the ultimate experience of loneliness as a developer. There were many concepts that as a non-blockchain developer I wasn’t familiar with and this made it harder to push through. So, I decided to learn about the key concepts and find answers to questions that I came across on my journey:

What is a smart contract?

A smart contract is very much like a normal contract, not significantly smarter, but a lot more secure. For example, a smart contract could specify family funds to be released automatically on someone’s 21st birthday. This transfer of money from one account to another is called a transaction.

What makes transactions secure?

Blockchain is the technology behind transactions in smart contracts. Blockchain is secured by having many computers verify the validity of transactions. A few transactions grouped together will form a block and computers/nodes will verify the block by calculating a hash of this block and appending it to the chain. This hash is actually the pointer pointing at the block, so if someone decided to tamper with transactions in a block the hash value would change and it wouldn’t be a valid block anymore. On top of that, the hash of the previous block is an input for the calculation of the hash of the current block, so if someone wants to change a transaction, they have to go back and change the hash of all the previous transactions. This requires so much computing power that you can consider it impossible. Calculating each hash takes a lot of computing resources, so people who provide this computing resource to verify transactions get paid with cryptocurrency in return. This is the process known as mining coins.

How do I create a smart contract?

Smart contracts live on blockchain platforms like Bitcoin and Ethereum. Even though Bitcoin is more well-known, Ethereum is more popular among the developer community. Perhaps because there are more resources and a larger developer community to help you get started. Solidity is the common programming language to write smart contracts on Ethereum.

Here’s what a hello-world contract looks like in our Solidity file HelloWorld.sol:

// Specifies the version of Solidity, using semantic versioning.
// Learn more: https://solidity.readthedocs.io/en/v0.5.10/layout-of-source-files.html#pragma
pragma solidity ^0.5.10;
// Defines a contract named `HelloWorld`.
// A contract is a collection of functions and data (its state).
// Once deployed, a contract resides at a specific address on the Ethereum blockchain.
// Learn more: https://solidity.readthedocs.io/en/v0.5.10/structure-of-a-contract.html
contract HelloWorld {
// Declares a state variable `message` of type `string`.
// State variables are variables whose values are permanently stored in contract storage.
// The keyword `public` makes variables accessible from outside a contract
// and creates a function that other contracts or clients can call to access the value.
string public message;
// Similar to many class-based object-oriented languages, a constructor is
// a special function that is only executed upon contract creation.
// Constructors are used to initialize the contract's data.
// Learn more: https://solidity.readthedocs.io/en/v0.5.10/contracts.html#constructors
constructor(string memory initMessage) public {
// Accepts a string argument `initMessage` and sets the value
// into the contract's `message` storage variable).
message = initMessage;
}
// A public function that accepts a string argument
// and updates the `message` storage variable.
function update(string memory newMessage) public {
message = newMessage;
}
}

Where do I deploy my contract?

The primary public Ethereum production blockchain network is called mainnet. When you’re first deploying your contracts, you can use testnets. You can think of a testnet as the dev environment and mainnet as the production environment for your smart contracts. When deploying a contract to a testnet, you still have to pay some fees, but instead of real money, you can use fake money from a faucet. If you want to learn more about this, check out Ethereum networks.

How do I get ETH from a faucet?

There are multiple faucets available where you can get test ETH but first, you’ll need a wallet and an account. A wallet is a product that allows you to interact with your Ethereum account, like view your account balance, send transactions, and more. You can create and manage your wallet using a tool like Metamask. An account is an entity that can send transactions on Ethereum. When you want to create an account, most libraries will generate a random private key and a public address. Account addresses start with a `0x` so if you are unsure about whether the string you are looking at is your address or not, this should hopefully make it easy to tell!

Next steps

From here, you can try following this tutorial on Hardhat to deploy your first smart contract. Here are some helpful resources you can use:

  • Metamask: creating and managing your wallet.
  • Infura: creating a project and connecting to ethereum with APIs.
  • web3/ethjs: Ethereum javascript API.
  • Kovan faucet: Get ETH for testnet.
  • lastpass: Helps you create strong passwords and not have to memorize them all.

--

--

Sayna Parsi
Sayna Parsi

Written by Sayna Parsi

Surreal inventor, plant-lover, magic-bean buyer, developer advocate @HERE

No responses yet