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

Aws services overview for AWS Certified Solutions Architect – Associate Exam

AWS Services Overview For  AWS Certified Solutions Architect – Associate Exam The AWS Certified Solutions Architect - Associate examination is intended for individuals who perform a solutions architect role and have one or more years of hands-on experience designing available, cost-efficient, fault-tolerant, and scalable distributed systems on AWS. Well, preparing for the exam and taking notes by watching content and reading blogs is kinda like more hurdles. So I am sharing this consolidated short overview of each AWS service which are needed to cover for the exam. AWS Compute services 1)     EC2 - Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides resizable compute capacity in the cloud. It is designed to make web-scale computing easier for developers. i.e. its a virtual machine inside the aws platform. It can have physical dedicated machines under EC2. 2)     EC2 container service - Where you can manage/run docker containers at scale. 3)