fbpx

If you’ve gone through a bunch of blogs riddled with code snippets and still have no clue about how to create a smart contract in Ethereum, you’re in the right place. We’ll help you sort it out without a single line of code — just the stuff a business owner needs to know.

To help you grasp the whole idea about developing smart contracts on Ethereum, let’s start off with an example.

Imagine an insurance company invents a new product — a blockchain-based travel insurance policy that compensates for delayed flights. Every passenger whose plane is late instantly gets a payout.

To pull this stunt, the company could build a smart contract application running on the Ethereum blockchain. Why not a regular web or mobile application?

Some would say it’s because smart contracts are smart — these mini-applications execute automatically when preprogrammed criteria are met. In our case, when a flight info API reports a delayed flight, a smart contract automatically initiates a payment to the insured.

Still, why not use a good old web (or mobile) app, working off a private server instead of the blockchain shenanigans? Keep reading to find out the answer and other details about how to develop a smart contract.

Table of Contents:

  1. Smart Contract Basics
  2. How Does a Smart Contract Work?
  3. Ethereum as a Platform for Creating dApps
  4. Programming Languages and Toolchain for Smart Contracts
  5. Develop a Smart Contract on Ethereum in 3 Steps
  6. How to Overcome Smart Contracts Shortcomings
  7. Time to Create an Ethereum Smart Contracts

Smart Contract Basics

Don’t worry if you haven’t followed every detail in our headfirst intro. We’ll quickly recap the main concepts you need to know for creating and deploying smart contracts.

Blockchain. The place where smart contracts live. It’s like a distributed, global database that exists on countless nodes registering transactions and any other changes on the network based on consensus by appending data blocks.

 

blockchain concept

There are different blockchains out there, but the one that’s most interesting to us in the light of smart contracts is Ethereum. It’s a so-called programmable blockchain. You can program it with smart contracts.

Eth — the Ethereum’s cryptocurrency generated (minted) by blockchain participants and required to carry out any transaction or execute a smart contract.

Smart contracts. These are programs written on a blockchain. You can code them on Ethereum, Hyperledger, EOS, and other blockchains. However, typically when their advantages are discussed, people talk about Ethereum-based smart contracts.

The apps that run on smart contracts are called decentralized apps (dapps) because when they run on a public blockchain, no single authority has control over them.

How Does a Smart Contract Work?

These apps are called smart contracts because they resemble written agreements, only rendered in code. They function on an if-then basis.

smart contract abstract concept

 

If predefined criteria are met, then a smart contract initiates an action. More often than not, it’s a payment, or it can be a transfer of ownership, or sometimes initiation of yet another smart contract.

Like any operation on a blockchain, every transaction performed by a smart contract is completely transparent and immutable, meaning it can’t be reversed.

Ethereum as a Platform for Creating dApps

You may be wondering, “When Do I Need to Make a Smart Contract on Ethereum?”

To keep things simple, you need a smart contract-based application on Ethereum when you can think of fully automated actions for your digital product. Let’s say you’re developing a fitness app that works on a blockchain, and users earn crypto every time they workout.

Let’s also assume that you’re tracking workouts with custom sensors that customers need to purchase. You can discern fake workouts from real ones with 99% accuracy using the data coming from these gadgets. In this case, you can implement a smart contract to automatically pay out X amount of your crypto (FitnessCoin or whatever you want to call it) to users’ Ethereum wallets after they spend X amount of time exercising.

fitness crypto concept

So, the real answer to the question, “Why not a regular application that has nothing to do with blockchain?” is the cost of operating such a product. It’s lower with automated digital contracts.

If we go back to the example of the insurance product from our intro (the one compensating for delayed flights) — even if it’s a web-based application, the insurance company needs operators and support staff to run it. However, when it’s a smart contract-based app (or dapp), it works on its own, drastically lowering the operational costs.

Another popular scenario for implementing smart contracts is initial coin offering (ICO). Let’s say you need to raise funds for developing this crypto-generating fitness app we referenced above. You run an ICO campaign, which among other things, implies minting virtual coins (FitnessCoin if you liked the name) and selling them to investors. To do that, you will need smart contracts: they are used to distribute purchased coins between users.

Programming Languages and Toolchain for Smart Contracts

There are several programming languages for coding smart contracts. Depending on a blockchain you’re working with, you will be choosing between:

  • Solidity or Vyper, to build smart contracts on Ethereum
  • C++, on the EOS blockchain
  • Golang, for Hyperledger

 

programming languages for smart contract development

 

Let’s also briefly mention other tools you might find useful to create your own smart contract. And while I don’t assume you’ll be coding yourself, it never hurts to have at least a high-level understanding of the skills required to get the job done.

IDEs (Integrated Development Environments) — software where programmers input code. Fortunately, there’s a couple that don’t require installation and setup because they’re entirely web-based:

  • Remix
  • EthFiddle

Frameworks are like toolkits with plug-and-play instruments to compile and deploy a smart contract on Ethereum. They come with utilities for testing on a local blockchain instance, integration options for building other components of your dapps, and other stuff that streamlines Ethereum smart contract deployment.

We'll provide insight into what tech stack and APIs work best for your app idea.
Tell me more
  • Truffle (comes with Ganache that allows you to quickly start a personal blockchain)
  • Hardhat
  • OpenZeppelin SDK

 

smart contracts app development on Ethereum banner

 

Finally, you’ll need testnets (also known as testchains) or local blockchain networks for testing purposes. They do not require real ETH (Ethereum cryptocurrency) to pay for executing a smart contract, and you can request as much ETH balance as you need. Another upside is that all transactions happen immediately without the need for the global network of online nodes to calculate and verify each transaction.

  • Rinkeby
  • Kovan
  • Ropsten

Among other things you’d need to start building smart contracts, we should also mention Geth, that allows us to run an Ethereum node, which in turn is necessary to interact with other nodes on the network.

Develop a Smart Contract on Ethereum in 3 Steps

On a very high-level, to build a smart contract, you need to:

  • write its code
  • test it
  • and finally, deploy it

Now let’s go through each step, so you know what to expect from your fintech development partner during the project before you start to build your own smart contract. [Note to developers: this is meant as a light tutorial on developing Ethereum smart contracts for beginners. So no code here.]

Related: How to Make a Trading and Investment App in 2021

steps to developing smart contract on ethereum

Code

Developers write code using an appropriate programming language. “What’s there to know?” you might ask. Well, just a few things, really.

  • Code describes the conditions for executing a contract: initiating a transaction or reaching out to another interconnected dapp.
  • There are special data feeds (called oracles) that are used to connect a smart contract to off-chain, real-life events, which can be part of its execution logic.
  • Developers can use open-source libraries (e.g., by OpenZeppelin) and templates. So, there’s no need to code everything from scratch.

Test

Once you put out a smart contract onto the Ethereum blockchain (also known as mainnet), it becomes immutable. This means you won’t be able to amend it. Alas, that’s not a  test-friendly scenario, right?

So what do you do to test a smart contract? You spin up a local blockchain (meaning all other nodes that make up a typical blockchain will live on your machine), or you use one of the testchains, e.g., Rinkeby.

If you are building a permissioned blockchain (i.e., the one that is not public) using Hyperledger, you will need these testnets: REMME, Hyperledger Umbra.

Blockchain smart contract concept with characters. Digital innov

 

What these private networks give you is instant transactions (no need to wait till another block is calculated by a node network) and free crypto, which is necessary for testing.

Deploy

By deploying, we mean placing your smart contract onto the blockchain, whether it’s Ethereum or Ethereum-based private blockchain. All it takes to deploy is making a transaction, which naturally requires spending crypto. So be prepared.

One other thing to note is that the smart contract also needs to be compiled before it’s deployed. By compilation, we mean converting its code into a JSON file that can be read by a regular web app.

That’s it. After these steps, you’re live, and the coded functions will kick into gears automatically when the programmed parameters will be met.

How to Overcome Smart Contracts Shortcomings

Despite all the hype about the decentralized future, there are still some disadvantages to using this technology that you should be aware of.

Smart contract web banner, e-signature document

Immutable code

Immutable code means you won’t be able to reverse a contract once it has been deployed. Therefore, the cost of a bug is significantly higher than with regular software that can be patched on the fly. Fortunately, there are plenty of readily available testing environments that simulate the blockchain.

When public is too public

Deploying a smart contract to Ethereum implies that everyone on this blockchain will have access to it. I doubt too many businesses are ready to make their operations that transparent. Of course, an Ethereum-based permissioned (read private) blockchain is always an option: Hyperledger is a great choice, for example.

Speed

It may take between 16 seconds and 5 minutes for a smart contract to transact on Ethereum. They are working on Ethereum 2.0 that will handle 10000 transactions per second, but right now, that’s only 30 transactions per second. And guess what, there are many people in the world transacting on Ethereum every second. Again, private blockchain effectively solves this challenge.

 

time to create and deploy smart contract and dapps

Time to Create an Ethereum Smart Contracts

As you can see, there are quite a few things to consider before you build a smart contract platform that will find real traction with users; this is also the case for fintech app development in general. At the moment, we’re building a cryptocurrency app to compete with the likes of Blockfi and Celsius. So if you’d like us to review your Ethereum-based app concept or offer advice, reach out today to schedule a call.

Frequently Asked Questions

Modern apps nearly always have the front end user (user interface) and back end (the server-side) parts working together. How does that apply to smart contracts?

Think of them as the back-end component of your application, holding its business logic. As for the front end piece, you’re free to develop it using any web or mobile technologies.

How to build a smart contract on Ethereum, using the native tools offered by the Ethereum community?

Use Solidity and Remix; both are offered by the Ethereum community.

How do smart contracts relate to Web3?

Web3 is the future of our current web technologies as we know and use them. While Gmail, Facebook, and other web applications are seen as Web2 apps, Web3 will be all about decentralized applications (fueled by dapps).

Is there a way to design a smart contract that has the benefit of being distributed on a shared ledger but at the same time does not reveal transactions to a wider public?

Yes, if you implement it on a private permissioned blockchain, for example, using Hyperledger, Azure Blockchain Workbench, or similar solutions.

Konstantin Kalinin
Technical Copywriter
Konstantin has worked with mobile apps since 2005 (pre-iPhone era). Helping startups and Fortune 100 companies deliver innovative apps while wearing multiple hats (consultant, delivery director, mobile agency owner, and app analyst), Konstantin has developed a deep appreciation of mobile and web technologies. He’s happy to share his knowledge with Topflight partners.

Looking for help with your app?

From a prototype to a full-blown app, we’ll help you hit the market
in record time with a product that’s set to win.
We can help with:
Schedule a Consultation
Strategy
From a prototype to a full-blown app, we’ll help you hit the market in record time with a product that’s set to win.
Design
Your app will have a unique visual appeal engaging your customers way beyond average digital experiences.
Development
We’ll pick relevant technology pieces for your app to make it secure and easy to scale up and maintain.
Schedule a Consultation

Have an idea?

Let's Work Together

Our industry-leading expertise with app development across healthcare, fintech, and ecommerce is why so many innovative companies choose us as their technology partner.

Learn how to build winning apps.

Privacy Policy: We hate spam and promise to keep your email address safe

Copy link