This smart contract tutorial will help you understand what is a smart contract.

This smart contract tutorial will help you understand what is a smart contract, why we need a smart contract, solidity for a smart contract, Blockchain implementation of the smart contract, voting process, hospitals and at the end you will see a use case implementation on crowdfunding smart contract.

Smart contracts are self-executing contracts which contain the terms and conditions of an agreement between the peers. A smart contract is very similar to a vending machine. It eliminates the need for intermediate and escrow services. The terms and conditions of an agreement are written in code. These agreements facilitate the exchange of money, shares, property etc. All of this process is executed in Blockchain’s decentralized platform. So, let us get started and understand what is a smart contract.

Below topics are explained in this smart contract tutorial:

1. Why smart contract? ( 00:33 )

2. What is a smart contract? ( 04:26 )

3. Solidity for smart contract ( 08:07 )

4. Blockchain implementation of a smart contract ( 09:56 )

5. Voting process 

6. Hospitals

7. Use case – Crowd funding smart contract ( 19:56 )


hello everyone and welcome to this

session of smart contracts my name is

Sarah and I’m part of the simple learn

team so let’s get started and understand

what is a smart contract what’s in it

for us today let’s understand why do we

need a smart contract what is a smart

contract usage of solidity for building

smart contract advantages or smart

contract blockchain implementation of

smart contracts we will look at certain

examples of voting and digital token and

also we will take another use case of

how smart contract help us do

crowdfunding now why smart contract now

let’s take a look traditionally how

contracts used to happen if suppose two

parties a and B have to get into a

contract they will utilize the services

of a third party whom they have to trust

and get the contract executed now with

the introduction of smart contracts and

the technology which is evolving it

removes the dependency on such third

parties and automates the execution of

such smart contracts so if we compare

traditional versus the new smart

contract in traditional we used to have

government’s lawyers or any other third

party on which we can trust in smart

contracts we don’t need any third party

we don’t need any intermediate execution

time definitely there is higher at

execution time in traditional contracts

because as many number of middlemen and

their intermediary layers that many

number of days and time takes smart

contract is just a matter of minutes it

gets executed because it is automated

programmable running on a computer and

it has some predefined conditions the

remittance if any remittance of either

of the parties have to happen then it is

a manual process approvals workflows


and these manual processes take time

under traditional contracting system but

in a smart contract as the conditions

are predefined pre embedded as soon as a

condition is met the remittance happens

automatically either of the parties who

have to be credited with an amount is

corrected automatically and that is the

primary advantage of using a smart

contract transparency not available 100%

in traditional contracts the

transparency is bound peripheral between

the parties and the entities and the

intermediaries involved as compared to

smart contract transparency is 100%

available 24 by 7 online anyone can go

and review audit and validate the

transactions executed by the smart

contracts archiving archiving is a big

difficult problem for traditional

contracts as most of the transactions

are paper-based or the records are

maintained offline it becomes very

difficult to maintain and identify the

traceability provenance of all the

transactions which have happened in a

traditional contract whereby in a smart

contract it becomes easy as all the

transactions have happened through the

smart contract there is a hundred

percent traceability available from the

provenance point of view you can trace

the transaction from its day one the

point of origin till presently

and archiving is automatically happening

the log the audit the transaction

history is automatically getting

generated security definitely is a

concern in traditional contracts as the

intermediate reason involved manual

processes involved security can be

compromised at any level at any stage

but in its Marc contract the security is

maintained through cryptography mainly

through public key infrastructure the

public and private key infrastructure it

is a very secure way of maintaining

security and cryptography of the

transactions using a smart contract cost

yes traditional contracts are expensive

the cost of transaction is high as

compared to smart contracts as the

middlemen are involved smart contract

the cost is low as we don’t have any

intermediaries and only the cost of

transaction is charged by the underlying

infrastructure of the blockchain Network

which is running the smart contract

signatures its manual process all the

transactions are signed manually and

verified manually but here in the smart


all the transactions are digitally

signed using the private key of the

entities and can only be decoded by the

public key shade by the parties involved

in the smart contract so in a nutshell

smart contracts give us n number of

advantages the primary advantages are

listed here and these are the advantages

which enforce us to move towards an

economy and to a system where we start

using smart contracts for our

transactions to avoid any disputes to

keep the transaction cost low thereby

giving the advantage to the end consumer

now what is a smart contract let’s

consider a real-life example where you

are taking out a chocolate from a

vending machine you deposit a $2.00 node

in a vending machine after that you hit

even button which is mapped against the

chocolate bar that you want to buy as a

result a liver in vending machine moves

and pushes out the chocolate so

basically even button is programmed to

the liver in order to move the chocolate

out now a smart contract is very similar

to a vending machine it eliminates the

need of an intermediary in case of the

vending machine is replacing a direct

seller and allowing you to make a

purchase without a middleman and it

eliminates the need of escrow services

now smart contracts are specific see

tooting contract which contain the terms

and conditions of an agreement between

the parties and the peers who are

involved in that agreement so the terms

and conditions of an agreement are

written in a piece of code and it is

executed on a blockchain based

decentralized platform now these

agreements Silla dates exchange of any

digital asset it could be digital


it could be shares it could be property

or it could be anything which you want

to transact so a blockchain based v

centralized platform gives you a

democratic system where the transactions

are authorized by the majority of the

participants and the identity of the

participants is also kept anonymous now

let’s consider an example where rachel

is at the airport and her flight is

delayed but this inconvenience could

have been beneficial to Richard as smart

contract insurance would ensure she is

given a compensation for the flights

delay instantly so just imagine there is

a smart contract which the insurance

company has already deployed and its


during the flights delayed Rachel has

already taken that insurance for delay

in flights so as soon as that condition

is met for a delay of flight above X

amount of hours for example two hours

then in that case the insurance company

will automatically get that trigger and

Rachel will be credited with that amount

for which she is insured in her account

so let’s see how smart contract can be

helpful here so X a flight delay

insurance is one of the examples of

aetherium smart contract AXA is an

insurance company the smart contract is

linked to the databases that record

flight status so that smart contract is

connected to the databases it is

fetching that information and evaluating

the delay it enables automatic

compensation when there is a delay for

two hours or more so that is the

condition when the flight delay is

beyond two hours then the insurance

contract will get executed and Rachel

will get paid a smart contract is

created based on the terms and

conditions so condition compensation is

equal to flight delays less than two

hours based on the code smart contract

holds the company’s money until a

certain condition is satisfied this

smart contract is submitted to the nodes

on the blockchain

network to their EVMs for evaluation

so EVM is a runtime compiler to execute

smart contracts code it is the brain it

is the electronic virtual machine which

executes the smart contract all nodes on

the network executing the code using the

EVM must come to the same result because

all the EVMs would have the same copy of

the smart contract deployed if flight is

delayed two or more our smart contract

will be self executed and the

compensation amount will be given to

Rachel and that is the objective of the

smart contract without involvement of

any middleman paperwork which ritual has

to do to submit and then the insurance

company going through the manual process

all that has been bypassed and rachel

has been compensated directly now let’s

understand why do we need solidity for

developing our smart contracts now here

comes the important question which

programming language does not contract

use there are two widely used

programming languages for writing Scania

smart contract solidity

serpent however on bloxy platform

solidity is widely used for implementing

smart contracts and this is what we were

going to talk about in our subsequent


now solidity is a high-level programming

language used for implementing smart

contracts it enables to check the

program at run time rather than compile

time solidity is a turing-complete

language it has all the conditions all

the while loops for route operators etc

which are there in any mature

programming language in order to write

your code in order to write your

conditions if you have certain loop if

you have while conditions etc now what

are the advantages of smart contracts as

we have already discussed there are no

intermediate reason vult the process

executes without the need of a third

party it’s an automated process they are

automated with the code which eliminates

manual effort for execution it’s the

high speed highly computed smart

contracts which runs on programming code

the speed of its execution is higher

than a traditional contract as data is

stored in the be centralized system the

chances of modifying the data is

difficult and I would say more than

impossible accuracy based on the

requirement terms and condition of a

contract is recorded accurately so as

soon as any transaction is recorded it

is registered on a blockchain network

and it is immutable transaction no one

can modify or make changes in any record

which has been added onto a blockchain

it was through a smart contract now

let’s take a look at certain blockchain

implementation of a smart contract using

block came in voting process can


voting mal practices a centralized

voting system faces a lot of problems

when it comes to tracking votes they

could be manipulated identities they

could be manipulation in counting there

could be biased decision making a smart

contract is introduced to eliminate all

these mal practices there are certain

predefined terms and conditions which

already set in the contract no voter can

vote from a digital identity for of any

other voter the counting is foolproof

every vote is registered on a blockchain

network and the counting is happening

automatically without any interference

from a third party or dependency on a

manual process so terms and condition

each ID should be attributed to just one

vote the validation is done by the users

on the Block C Network itself so the

voting process can be in a public

blockchain or it could be in a

decentralized autonomous organization

based blockchain setup also but it is

100 percent transparent and every voting

transaction is recorded result every

voters would get recorded on the ledger

and that information cannot be modified

it is transparently publicly available

for audit and verification now let’s

take a look at one of the examples of

our voting solidity contract so here we

have our voting solidity contract it is

built in solidity and I’ll just give you

a brief overview of what are the primary

functions in this so if we look at this

particular contract this contract gives

you certain basic parameters like what

should be the minimum number of

participants or proposals which are

required for voting then what should be

the minimum amount of time for debate

that needs to pass before the vote can

be executed then the margin of votes for

majority a proposal passes if there are

more than 50% of the votes plus the

margin so basically we are defining what

is the winning condition what is the

majority margin for any world to be

accepted then you have data structure

where you are accepting the proposals

right and then subsequently we are

defining data structures for members who

are participating in the proposals who

are submitting the proposals we are

fetching the addresses of the members

basically this is the digital identity

of the members who are submitting the

proposals and etc so this smart

contracts basically allows you to create

a voting system where you can add

members we can remove the members you

can change certain voting rules based on

certain conditions like if you want to

increase the minimum forum if you want

to change the debating period minutes or

the majority rule changes then this is

the function for submitting a new

proposal for which the voting has to

happen so basically this example is

about if I have to take a vote within a


autonomous organization for a particular

decision so rather than a central

authority taking a decision you can have

a voting mechanism within your

organization to give a majority to your

proposal if you get the majority the

proposal is accepted otherwise reject

then there are peripheral functions like

check proposal code then there is a

voting function the actual vote happens

and for a particular proposal you start

increasing or decreasing the number of

votes then you execute the proposal if

the majority has been achieved now let’s

take a look on how to deploy a smart

contract so here we have our voting

smart contract now we will take a look

on how to deploy our voting smart

contract on the etherium test network

called rob stone this is our voting

smart contract now when you open remakes

you should also have meta mask which is

a chrome plug-in installed this is a

utility in order to connect to the Rob

stone test net which is a etherium test

network so basically you say Rob

standard ether scan dot IO and this is

the etherium test network on which we

will deploy our contract so once you

login into the meta mask you will have a

account created and in that account you

should have some test ethers already so

that you can use them to deploy a

contract so when you create an account

on Rob’s turn you can buy certain ethers

using the Rob stone test faucet

so when you reach this site that option

test faucet has already taken the

address for the account for which you

are erasing the request and you can

raise request of one ether now whenever

this transaction will get processed your

account balance will get incremented by

one so as I already have eaters in it I

can utilize it to deploy my contract now

in order to compile and deploy my

contract I have copy pasted it here and

if I go to my run my remix as already

communicated via injected web 3 to the

meta mas and taken my account which has

seven point eight three ether

now I need to do some settings


now as my contract is compiled you can

see it has taken all the contracts you

can see the drop down and Congress is my

major contract now I will deploy my

contract on the run section you will be

able to see in the drop down the name of

the contracts which are there in my

smart contract like I had own token

recipient then there’s an interface and

there is a Congress I need to deploy my

Congress contract now in order to deploy

this contract there is a constructor

which requires certain inputs so I can

give certain values like what minimum

number of proposals an 800 then minimum

number of debates 10 and margin of votes

for majority I say deploy now as soon as

I’ll click deploy it is going to request

me for gas because when the contract

gets deployed it will deduct certain

ethers from my account so when I will

say submit

if you notice now this transaction has

got initiated on the Rob’s train ether

scan dot IO I click on it so this is the

transaction on which the contract is

getting deployed it is taking time and

the contract is getting processed on the

etherium Network now once it will get

deployed we will be able to see the

address at which the contract has got

reiated and deployed now as you can see

my contract has got deployed at the

address 0 xcc I can load it so this is

the contract address and this is the

amount of actual ether which was spent

from my account in order to deploy the


now there are certain attributes on the

option either scan which you can go and

check you can verify and publish or

smart contract over here so that others

can also view the code and utilize your

smart contract and if you go and check

your meta mask this is the transaction

which has just been done in your account

and if you click it will take you to the

same transaction which we open there now

after you have deployed the contract you

can interact with your contract directly

through remix just to test your contract

all the pink members are the ones which

make changes onto the blockchain and all

the blue ones are the ones which are

only performing read operations so in

order to do any read operation you will

not be requested to spend any gas so

there will be no pop-ups for meta masks

requesting for gas pending but if you do

any of these pink actions then you will

be required to spend gas as it will be

requiring to make some changes onto the

blockchain so this was a example of a

voting smart contract and this will be

available as a link for you to take a

look now all our other contracts which

we will be covering subsequently will be

deployed in a similar fashion on the

robson test net now let’s take another

example if you want to use smart

contract to issue your own

cryptocurrency or called digital token

you can use aetherium based mat contract

to create your own digital tokens for

performing transactions in design and

issue your own digital currency create a

tradable computerized token that can be

utilized as a currency share or any

asset which you want to transact these

tokens use a standard coin API like in

case of aetherium we have

standardizations of ERC to 0 etc which

allows contract to automatically access

any wallet for exchange as a result you

build a tradable token with a suffix

applied and this particular platform

becomes like a central bank issuing our

digital money your smart contract

becomes the bank issuing the money so

let’s take this example here so this is

a implementation of a ERC 2-0 token

which is a specification by it

and the primary attribute for this token

is that you need to provide a name of

your token a symbol the decimals to

which you support and the most primary

is the predefined supply so just like in

an economy you have limited supply of

money there also you have to define what

will be the supply of your tokens and it

will be capped that will be discipline

so you need to redefine these parameters

and then you create certain data

structures within solidity to keep a tab

on the balances of the entities to which

you are giving the tokens and how much

allowance you want to keep for address

then there are certain methods which you

have to implement as per the ER c20

specification like transfer transfer

from approve and call etc so all these

methods in a typical token allows you to

do the transaction send and receive your

custom token among multiple parties so

this would also be available as a link

for you to take a look now let’s take

another example of a use case for

crowdfunding using smart contracts to

crowd fund your project so suppose you

want to start a business and for a

business you need a lot of funding which

is required but who would lend it money

to someone whom they don’t trust how

will you generate that money for such

problems smart contractor is a major

rule with aetherium you can build a

smart contract that will hold a

contributors funds unless a given date

or a goal is met based on the result the

funds will be released to the contract

owners or will be sent back to the

contributors so basically you can create

a crowdfunding project for yourself if

you want to raise certain amount of

money and the contributors or the

investors will give you the money but

the amount will be kept on hold till the

time your project goal or date has been

made and accordingly the investors will

get your the token which you have

developed for crowdfunding in earth or

is account accordingly now centralized

crowdfunding system has plenty of issues

with management systems so therefore a

dhow a decentralized autonomous

organization is utilized for

crowdfunding the terms and conditions

are transparently set in the contract


visual participating in the crowdfunding

is given a token and the token is

credited to their aetherium base account

now every contribution gets recorded on

the blockchain because then the token

transfer has happened from the DAO to

the individual investor that transaction

get recorded on the blockchain network

so let’s quickly take a look at the

contract for a crowd sale also so a

crowd sale contract provides you the

basic attributes like what is the goal

of the funding how much money you need

to raise what is the amount raised

real-time you can keep a track what is

the deadline right and what is the price

of the token in etherium basically what

is the your token amount in ethier

then there could be that you might give

certain tokens in reward then you can

have attributes for your reward and then

you have your methods in order to keep a

check that once you have received the

funds you can withdraw the funds you can

check whether you have reached the goal

for funding and then you have the

methods for transferring tokens from the

sender to your own account this

particular kind of contract allows you

to maintain and keep a check on amount

of funding you have received or you want

to receive have you achieved your target

who are the investors in Europe token

how much percentage share belongs to

your account and how much percentage

share has been already been distributed

all amongst the investors etc so

everything can be tracked so the smart

contract can build in such a fashion

that there are methods and utilities

available in order to run your entire

crowdfunding so this contract is also

available in the link and you can take a

look so what are the key takeaways today

why do we need smart contract what is a

smart contract what are the advantages

of smart contract blockchain based

implementations or smart contract and

the use case of crowdfunding using smart

contracts I hope you all had a great

learning session and I’ll meet you in my

next session

thank you