Skip to main content

Easiest way to understand how the Ethereum Smart Contract work

Ethereum is one the fastest growing block chain with ever growing eco-system. It's beautiful in that, unlike Bitcoin, it's not just a currency, it's a complete platform for Decentralized Application (Dapp). Ethereum as currency just being one of the many application of the platform. Sheer enthusiasm about this currency in recent times has caused emergence of tonnes of technologies around it. Once you start reading about ethereum you will be hit by technical Jargons at 1 jargon per minute speed.

Hence, this article is an attempt to help you visualize one aspect of the Ethereum system, ie. how smart contract work.

Imagine you want to create a bank where users can manage their accounts. Also, any other third party bank should be able to integrate with your super awesome bank. So, you create a following piece of code.

class Bank{
    Map<String, Double> accountMap;
    public void transferTo(String accountNumber, double amount){
        double balance = accountMap.get(accountNumber);
        accountMap.put(accountNumber, balance + amount);
    public void withdrawFrom(String accountNumber, double amount){
        double balance = accountMap.get(accountNumber);
        accountMap.put(accountNumber, balance - amount);
    public double getBalance(String accountNumber){
        return accountMap.get(accountNumber);

But this is of little use because account state is stored in RAM (heap), and is volatile. You will need to persist it in database. You will have to host it publicly and make sure it's up 24x7.

Ethereum handles it by replicating same program on thousands of machines. Imagine as if each program shares the state of the member variables with each other. Interested people can create their apps around your program and they can pass on queries from their system to your intelligent bank.

What we have written just now is essentially an Ethereum smart contract (except that it should be translated into Solidity, the Ethereum programming language)

Hope this gives different perspective in the understanding of Ethereum Smart Contracts.

Suggestions / queries are most welcome.


  1. Great Article
    Cloud Computing Projects

    Networking Projects

    Final Year Projects for CSE

    JavaScript Training in Chennai

    JavaScript Training in Chennai

    The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training


Post a Comment

Popular posts from this blog

Auto Scaling DynamoDB

Those of you who have worked with the DynamoDB long enough, will be aware of the tricky scaling policies of DynamoDB. It allows user to explicitly set requests per second (units per second, but for simplicity we will just say request per second). User can do so for read as well as write operations. Anytime user can increase or decrease the provision capacity from DynamoDB web console and it will reflect immediately. Sounds all good....... Or not? What if you set provisioned capacity to 50 req per second but load on the server crosses 100 req per second? Requests gets throttled!! Mostly times out. What's worse? This can cause requests getting queued up in your web server. Which can potentially bring your entire server down. What if you set provisioned capacity to 1000 req per second but load on the server is only 100 req per second through out the day? You lose your hard earned money for remaining 900 req per second. What if you set it to 1000 req per sec and then realis

StackDriver Integration with AWS Elastic Beanstalk - Part 1

Stack Driver Setup Step 1: Create stackdriver project Navigate to  After logging in you will be redirected to project creation page. To manage multiple environments of your application its advisable that you create just two projects. One for production env and other one for non-prod. Even though you might have multiple non-production environments, but having one stackdriver project per application-env is overkill. So, lets start with production project. For this tutorial, I'll create CodeHooDoo-Prod project. Once the project is created, StackDriver will ask you to link your AWS account resources to it for monitoring.  But as AWS CloudWatch has good monitoring and alerting support you can skip this one. Keep clicking continue until you get to monitoring console. Click on the logging. This is where you will get all the logs from your application server. Step 2: Download authentication key Navigate backt to .