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

Going deep into the Instagram’s feed ranking algorithm

Going deep into the Instagram’s feed ranking algorithm Ranking algorithms means feed posts showing up based on what Instagram thinks you want to see and not just the newest posts first. Let's check the Instagram’s giant feed handling –   They never revealed how the feed algorithm worked until they called upon a group of reporters to their San-Francisco office and pulled the curtains off from the Instagram feed ranking algorithm. They explained the reporters that there were three factors where an individual’s engagement to the app is taken care of, the three being: -

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