BLOG

Blockchain development with Smart Contracts

Blockchain development with Smart Contracts

Matias Morales

Software Developer

Sep 5, 2022

4 min read

JavaScript

Backend

Alice and Bob are having a bicycle race. Let’s say Alice bets Bob $10 that she will win the race. Bob is confident he’ll be the winner and agrees to the bet. In the end, Alice finishes the race well ahead of Bob and is the clear winner. But Bob refuses to pay out on the bet, claiming Alice must have cheated.

This silly example illustrates the problem with any non-smart agreement. Even if the conditions of it agreement get met, you must still trust another person to fulfill it agreement.

What is a Smart Contract?

A “smart contract” is simply a program that runs on the Ethereum blockchain. It’s a collection of code (its functions) and data (its state) that resides at a specific address on the Ethereum blockchain.

Traditional Transactions VS Smart Contracts

Automatic execution

One of the most significant benefits smart contracts have over regular contracts is that the outcome is automatically executed when the contract conditions are realized. There is no need to wait for a human to achieve the result. In other words: smart contracts remove the need for trust.

How Smart Contracts work

Predictable outcomes

The human factor is one of the biggest points of failure with traditional contracts. Smart contracts remove the possibility of different interpretations. Instead, smart contracts execute precisely based on the conditions written within the contract’s code. This precision means that the smart contract will produce the same result given the same circumstances.

Smart contracts remove the possibility of different interpretations

Public record

Smart contracts are also useful for audits and tracking. Since Ethereum smart
contracts are on a public blockchain, anyone can instantly track asset transfers
and other related information.

Privacy Protection

Smart contracts can also protect our privacy. Since Ethereum is a pseudonymous network (your transactions are tied publicly to a unique cryptographic address, not your identity), you can protect your privacy from observers. You can find GoGrow’s public basic Solidity Smart Contracts examples here.

GoGrow’s public basic Solidity Smart Contracts examples

Development tools

Remix Ethereum (remix.ethereum.org): Remix IDE allows for developing, deploying and administering smart contracts for Ethereum-like blockchains. It can also be used as a learning platform.

Truffle (https://trufflesuite.com/): Is a development environment and testing framework for blockchains using the Ethereum Virtual Machine (EVM) aiming to make life as a developer easier.

Truffle project structure:

Truffle project structure

Client: Contains the frontend; it’s a React application structure.

Contracts: Contains the smart contracts files.

Migrations: Commonly Javascript files used to deploy the smart contracts using truffle deployment helpers.

Test: Contains the Smart Contracts test files.

Truffle Config: Configuration file, where you can specify the network to use and compiler version for the Smart Contracts language.

Ganache (https://trufflesuite.com/): A personal blockchain for Ethereum development you can use to deploy contracts, develop your applications, and run tests.

Ganache

OpenZepellin Contracts

(https://github.com/OpenZeppelin/openzeppelin-contracts)
A library for secure smart contract development. Build on a solid foundation of community-vetted code.
Provides:
● Implementations of standards like ERC20 and ERC721
● Flexible role-based permissioning scheme
● Reusable Solidity components

● Smart contract size limit (24 kb)
● They are Immutable
● Ethereum blockchain supports around 15 TPS (expected ~ 100,000 TPS with the upcoming PoS mechanism)
● Connection with real-world events

Conclusion

Smart contracts are computer programs that live on the blockchain. They can
execute automatically. You can track their transactions, predict how they act and even use them pseudonymously.

Smart contracts can do essentially anything that other computer programs do.
They can perform computations, create currency, store data, mint NFTs, send
communications and even generate graphics.

There are a lot of resources and tools to learn about blockchain development. On top of this there is also a large community of developers and decentralization enthusiasts building the fundamentals of this technology revolution.

Resources to learn about blockchain development:
https://www.learnweb3.io/
https://ethereum.org/en/developers/docs/intro-to-ethereum/
https://www.openzeppelin.com/contracts

Matias Morales

Software Developer

Sep 5, 2022

4 min read

JavaScript

Backend

BLOG

Unlock forbidden knowledge

Explore more

Arrow Icon
Efficiently Caching Translations in React with Zustand and Google Translate API

Frontend

Guides

Efficiently Caching Translations in React with Zustand and Google Translate API

Learn to integrate Zustand and Google Translate API for a seamless translation feature. Cache results to reduce API calls, boost performance, and enhance scalability.

Mauro Davoli

Fast API Development with Hono and Cloudflare Workers

Backend

Technology

Guides

Fast API Development with Hono and Cloudflare Workers

Pablo shares his journey of finding tools to build REST APIs quickly and efficiently. He highlights his experience with Hono, a lightweight framework reminiscent of Express, designed specifically for Cloudflare Workers.

Pablo Haller

A step-by-step infographic showing the process to set up authentication with Next.js using the next-auth library.

Guides

Technology

Basic GitHub OAuth Authentication with Next.js and next-auth

This blog explains how to set up GitHub OAuth in Next.js using next-auth. It covers creating a GitHub OAuth app, configuring environment variables, integrating authentication with a custom route, protecting routes, and managing sessions.

Pablo Haller