Professional Documents
Culture Documents
B LO C KC H A I N
Submitted by:
HANSIKA SHISHODIA
Supervisor:
PROF. DIRK PESCH
Second Reader:
DR JOHN HERBERT
September 1, 2019
Hansika Shishodia: Recording Volunteering Efforts on Blockchain, MSc in Com-
puting Science, © September 1, 2019
ii
Abstract
The credits are earned as tokens on the blockchain which makes them
tamper-proof and everlasting. The monetary value of blockchain tokens
is highly influenced by the inflation/deflation of currency. Therefore, this
application rewards volunteers with its custom-created tokens which are
awarded for the number of hours spent in volunteering. As earned, these
tokens can be redeemed in the future for hourly services. Taking time
as a parameter to reward the work ensures that the approach is cashless
and does not lose its value over the years. The thesis finds that Ethereum
blockchain, inspite of being a new technology going through its own devel-
opment, can facilitate custom token creation which can then be used as
alternate currency in various sectors as volunteering, the one used in this
project.
Declaration
I confirm that, except where indicated through the proper use of citations and references,
this is my original work and that I have not submitted it for any other course or degree.
Signed:
Hansika Shishodia
September 1, 2019
iii
Acknowledgements
Firstly, I would like to express my sincere gratitude to my supervisor Prof. Dirk Pesch
from University College Cork, for the continuous guidance and accurate feedback
throughout my research and development. He helped me to understand the require-
ments better and frame the work, without his rigorous comments the thesis would not
have been of the same technical and scientific quality.
I would also like to thank Patrick Mulvihill from Independent Living Ireland(ILI)
organisation who was always there to help and support my work by providing his insight
from the business perspective. His precise and detailed directives provided me impor-
tant guidelines concerning the architecture of the volunteering system application.
iv
Contents
Contents v
1 Introduction 1
1.1 Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Research Question . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Aims and Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 Personal Contribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.5 Report Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Literature Review 5
2.1 Community Currencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.1 Alternate Currencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.2 Loyalty Reward Points System . . . . . . . . . . . . . . . . . . . . . . 6
2.2 Blockchain Technology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.1 General Blockchain Concepts . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.2 Types of Blockchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2.3 Ethereum Blockchain . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3 Loyalty Points: Blockchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.3.1 Existing Real-World Systems . . . . . . . . . . . . . . . . . . . . . . . 18
3 Analysis 20
3.1 Functional Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.2 Non-Functional Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.3 Project Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.3.1 Web Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.3.2 Ethereum Blockchain Platform . . . . . . . . . . . . . . . . . . . . . . 23
3.3.3 Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4 Design 24
v
Contents vi
5 Implementation 29
5.1 Entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.1.1 Admin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.1.2 Volunteers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.1.3 Organizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.2 Components outside the blockchain . . . . . . . . . . . . . . . . . . . . . . . 30
5.2.1 Node.js Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.2.2 Front-End Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.2.3 Firebase Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.3 Blockchain components for smart contract . . . . . . . . . . . . . . . . . . . 36
5.3.1 Ethereum Testnets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.3.2 Metamask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.3.3 Etherscan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.3.4 Remix IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.4 Tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.4.1 Token Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
7 Final Conclusion 50
A Developer’s Manual 52
A.1 VOGen Smart Contract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
A.1.1 SafeMath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
A.1.2 IERC20 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
A.1.3 Owner Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
A.1.4 VOGen Smart Contract . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
A.2 Web3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
A.3 Firebase Database Configuration . . . . . . . . . . . . . . . . . . . . . . . . . 55
Bibliography 57
List of Tables
vii
List of Figures
viii
Chapter 1
Introduction
The elderly population in the world is increasing remarkably. Presently, as per the United
Nations report, Europe is the greatest contributor with 25 percent of the total population
aged 65years or above. Ireland is getting older at an even faster pace. The number of
older people in Ireland has increased by 32.8 percent since 2007, a faster rate of growth
than other EU countries. By the year 2031, there will be nearly a million people in the
country aged 60 years and above.
As people grow old, they need extra care and support. In general, Ireland’s community,
voluntary and charity sector make a very substantial contribution to society. The sector
has combined annual turnover of over €14.5bn, benefits from the voluntary work of
over 50,000 volunteer board members/directors and the work of over half a million
"operational" volunteers, (valued by the Central Statistics Office(CSO) at around €2bn
per year) [Ryan 2018].
However, the reliance of this sector on the capitalist economy makes it susceptible
to market fluctuations and economic crisis. In a report by Indecon International Eco-
nomic Consultants, John Farrelly, Charities Regulator Chief Executive said "At one end
of the scale there are large hospitals and universities with budgets funded by the Ex-
chequer, extending to hundreds of millions of euro, and hundreds of paid staff. Many
of these are large charities engaged in delivering critical health, education, and social
services. On the other end of the scale, there are completely volunteer-led organizations,
providing services at the community level, with small budgets."
The changing lifestyles, lack of motivation, work stress and work-life imbalance
are the personal barriers that refrain people from contributing to society. In addition
to these, searching for opportunities on multiple websites and maintaining various
user accounts with different organizations are also prominent reasons behind reduced
volunteering.
"What role can technology play in improving the volunteering in Ireland through the
integration of an alternate payback currency?"
This will have a dual advantage as it involves mental satisfaction of doing something
meaningful for the society as well as being appreciated for that, in the form of some
currency that can be utilized for self-care in the future.
tion to age gracefully by being a part of the society but also demonstrate to the younger
generation about the benefits of aging in the community. It will improve the quality of
life of the aged population along with building and maintaining trust, compassion, and
cooperation in the society.
Since this is a research and development work, the research on the existing work
done in this field initially shapes the project. The present thesis work is motivated by the
will to clarify the power of the blockchain technology and use it in the volunteering sector
as a loyalty point reward system. It is motivated by the purpose of using state-of-the-
art technology to improve upon the traditional system, which lacks risk management,
immutability, transparency, and privacy.
Chapter 3: Analysis
This section presents the approach that can be taken in dealing with the questions
mentioned in the report. It describes the various functional and non functional require-
ments of the project. Also, the brief discussion about the technologies to be used and
their suitability for this type of work is being analysed in this segment.
Chapter 5: Implementation
As this is a research and development paper, the development chapter will give
detail on the technical aspects of the project that help to realise how every requirement
is addressed and tried to be resolved in the volunteering sector. It is proposed that this
system can be developed on beyond the prototype phase to support the volunteering
sector in Ireland.
Chapter 7: Conclusion
The research paper concludes with a final opinion on the project in terms of the
researcher’s learning and contribution. It also deals with the future scope of this project
that requires further investigation.
Literature Review
This research is seeking to understand the role of blockchain technology in helping and
encouraging the volunteering sector. Numerous approaches across the globe have been
made in the form of alternate currencies, volunteering and reward points to support
various social and financial causes. In this literature review we will see the various
alternate currencies that prevail in the society to solve different issues: the reward point
system and how can these be transformed digitally in a blockchain system to ensure
trust and transparency.
The time based credits can be earned and redeemed for the hourly services provided
and received. This can be explained as in Figure 2.1 below.
It is not just the social challenges that lead to the rise of alternative currencies.
There are many forms of it, including the existing commercial loyalty points, which are
the largest alternative currency systems today, the most widespread of which are the
airlines’ programs. The following section presents some existing reward points systems
prevailing in the society, which might be used in my project implementation.
In spite of adding and maintaining the targeted customer base, these traditional
approaches do have some challenges and limitations from the perspective of both the
customers and the company [Agrawal et al. 2018].
2.1 COMMUNITY CURRENCIES 7
• The first and foremost challenge is to appropriately estimate the liabilities at the
time of redemption of the loyalty points.
• Secondly, the selection of the right loyalty program that will best suit the com-
pany needs is a challenge as providing the loyalty points does not guarantee the secured
share market. Thus, the loyalty point system can be considered just as a way to entice
loyalty in a customer.
• Finally, managing a database for all the customers and their purchases is an extra
overhead due to the additional infrastructure and maintenance needed.
• Furthermore, the limitations and the conditions of utilizing the points are not
always mentioned initially but are presented upon the successful registration with the
program.
• Additionally, the customers tend to sign for multiple companies for the reward
points on offer and often end up in neglecting the points as the desired limit is not
attained to redeem for the desired product/service or at times the tracking system is not
clear enough to keep going.
• Moreover, the loyalty programs might create switching cost for the customers,
that is, often at times there are better deals available elsewhere on a given product/service
but since the customers has enrolled to a loyalty program they opt for the loyalty pro-
gram service to earn the points.
• Lastly, customers have to keep themselves updated on the changing terms and
conditions of the company. This discourages customers to participate in the programs
due to misunderstandings and disappointments.
These loyalty points have become tired and need to be reinvented for more person-
alized, relevant and exclusive customer experiences. Hence, building the loyalty reward
programs on top of the blockchain will resolve the majority of issues and provide a new
exciting experience for the customers as well the companies. Blockchain is just a system
facilitator and not a replacement of the existing system.
2.2 BLOCKCHAIN TECHNOLOGY 8
Blockchain is a distributed ledger that is shared on all the nodes connected in the
network and is cryptographically immutable. It ensures transparency and unlike the
banking systems, the technology is decentralized.
The transformation of blockchain technology has been very impressive over the last
decade and it will be intriguing to see where the next decade takes us.
• less time and less money for the interaction with contractual partners;
• the removal of a central governing authority, which is a single-point-of-failure
Ledger:
A blockchain is a digital form of any traditional physical paper-based ledger where
all the records are maintained. These records are stored to keep a track of the transaction
history that was ever done on the blockchain network.
Cryptographic immutability:
The blockchain ledger is cryptographically immutable in a way that whenever a
transaction is added to the chain, the block is made immutable by using a cryptographic
algorithm.
[C] Working
Before deepening the process of a blockchain transaction, certain terms and concepts
need to be understood. Some of them are:
Blocks: These store the details of a transaction made on the blockchain. The blocks
are added to the chain in chronological order. Every block has its data along with the
hash value of the previous block which makes the chain immutable. A single change in
the block will alter its matching with the hash of the next block and thus can be detected.
2.2 BLOCKCHAIN TECHNOLOGY 10
Mining: This is the activity that is performed to add a block to the blockchain. The
miners create their blocks of unconfirmed transactions and compete to solve the math-
ematical puzzle designed uniquely for each block [Blockchain: how mining works and
transactions are processed 2018].
The miner who solves the puzzle in the minimum time is awarded the blockchain
currency or tokens as a computation fee, which is for the time and computational efforts
put in solving the problem. This process is called mining where miners make computa-
tions to add their block of transactions to the chain and get rewarded in the form of a
cryptocurrency. Figure 2.2 describes the working of a blockchain system.
The technology works in a way that when any transaction is made, it is added to
a pool and miners pick the transactions from the pool to create their blocks having a
timestamp. The block data is sent as input to a hashing function to produce a hash value.
This hash value is mapped against the hash standard which is set differently for every
type of blockchain. The combination of the transactions in the block might not produce
the required hash value and thus, miners keep trying new combinations through setting
a different nonce.
Once a miner produces a hash value for a block that matches the conditions of
the hash standards of the blockchain system, he shares the block and the generated
signature with all other nodes. The nodes verify the work by generating the new hash
and matching it with the shared signature. And hence, blockchain is based on the
proof-of-work consensus. Once the proof of computational work done by a miner is
2.2 BLOCKCHAIN TECHNOLOGY 11
The other nodes might as well be sharing their blocks and here comes the time
stamp into picture which enables sequential aligning of the blocks in a chain. This chain
is secured using a hash which makes the links between the blocks unbreakable. All the
nodes on the network have the same chain information at any given point.
The security of data on the network chain is achieved by adding the hash code of this
block in the next block ensuring a trace of the hash function is woven into the new hash.
This happens for all the blocks throughout the chain. Hence, any change in any of the
previous block would mean that the hash on the block will not match with the encoded
hash in the next block. This will continue through the chain depicting an alteration in
the chain. This mechanism of hash chaining provides the surety of tamper-proof data.
Public: These can be accessed by anyone as these do not have any central authority
[Buterin 2015]. Anyone can make transactions and can also be a part of the consensus
needed to verify the transactions by other using some cryptographic mechanisms. The
best example of this is the Bitcoin currency.
Private: Here, a single authority or the company owns the right of writing and
verifying the correctness of any operation. These are fast and secured as compared to
public blockchain for the very simple reason of access being provided to limited group
of people.
Permissionless: These blockchain does not require authorisation from any existing
node in the network. The joining node is free to participate in the validation process.
Table 2.1 below illustrates the major differences between the various types of
2.2 BLOCKCHAIN TECHNOLOGY 12
blockchains.
Voting or Voting or
Proof of Work,
Consensus multi-party multi-party
Proof of Stake,
Mechanism consensus consensus
etc..
algorithm algorithm
Transaction
Long Bitcoin: Short Short
Approval
10 min or more 100x msec 100x msec
Frequency
Simplicity: The Ethereum platform is kept as simple as possible to ensure that any
developer unschooled in Ethereum can use the platform to make Dapps using smart
contracts. As per the founders, simplicity is the key concept worthy enough to sacrifice
cost and time. The white paper states that any optimizations that add complexity should
not be added unless it provides some substantial benefits.
Want to invent your own financial derivative? With Ethereum, you can. Want to
make your own currency? Set it up as an Ethereum contract. Want to set up a full-scale
Daemon or Skynet? You may need to have a few thousand interlocking contracts and be
sure to feed them generously, to do that, but nothing is stopping you with Ethereum at
your fingertips.
Modularity: Ethereum has been designed as modular in a way that it is divided into
smaller separable modules. The intention behind is to enable making changes in one
part of the program without impacting the entire application. The white paper presents
2.2 BLOCKCHAIN TECHNOLOGY 14
Over the course of development, our goal is to create a program where if one was to
make a small protocol modification in one place, the application stack would continue
to function without any further modification. Innovations(such as Ethash, modified
Patricia trees and RLP) should be, and are, implemented as separate, feature-complete
libraries. This is so that even though they are used in Ethereum, even if Ethereum does not
require certain features, such features are still usable in other protocols as well. Ethereum
development should be maximally done to benefit the entire cryptocurrency ecosystem,
not just itself.
Agility: The Ethereum protocol details are not stone set. They are agile and accept
modifications although the founders have made clear that:
All regulatory mechanisms in the protocol should be designed to directly regulate the
harm and not attempt to oppose specific undesirable applications. A programmer can
even run an infinite loop script on top of Ethereum for as long as they are willing to keep
paying the per-computational-step transaction fee.
• The nonce, a counter used to make sure each transaction can only be processed
once
[C] Transactions
The term "transaction" is used in Ethereum to refer to the signed data package that
stores a message to be sent from an externally owned account [Ray 2014]. Transactions
contain:
• A GASPRICE value, representing the fee the sender pays per computational step
The first three terms are the same for any transaction, as we saw in the blockchain
section above. The data field has no function by default, but the virtual machine has an
opcode which a contract can use to access the data.
The STARTGAS and GASPRICE are crucial to ensure the anti-denial of service in
ethereum blockchain. The fixing of the computational steps for a transaction is to
prevent any infinite loops that might occur. "Gas" is the basic unit for any computation
and is usually 1 gas per computation step. The fee system is implemented to ensure that
in case of any potential attacks, the attacker also pays for the computation and other
resources used. Hence, greater network consumption will roughly increase the gas fee
in the same proportion.
The public key is used as an address for the whole of the world, the private key is
used in transaction validation [Ray 2014]. The private key and the amount of currency is
put in the blockchain software. Other nodes can plug the public key(known to everyone)
2.2 BLOCKCHAIN TECHNOLOGY 16
into the blockchain program and check if the user holds at least the amount of tokens
he wants to send. And thus, the transaction is validated based on this.
The EMV is a transaction singleton machine with a shared state. In computing, this
means it behaves like one giant data object, rather than what it is: a network of discrete
machines, themselves singletons, in constant communication. From the perspective of
a software developer, the EVM is also a runtime environment for small programs that
can be executed by the network.
EVM is like a state machine as it maintains the history of all the transactions ever
done. Each transaction in the memory bank can lead back to the very first transaction.
EVM is the most trustful and reliable machine that any global network has today.
For every instruction the EVM executes, there must be a cost associated, to discourage
useless contracts deployment (for that testnets exist). Every time an instruction exe-
cutes an internal counter keeps track of the fees incurred, which are charged to who is
performing them. Each time a sender initiates a transaction that’s user wallet reserves
always a small portion to pay fees. After a transaction has been broadcast to the network
from a given node, the network propagates the transaction around so that all the nodes
can include it in the latest block.
Implementations: The main network has a list of live EVMs [Feliam 2018]. Some of
those are:
• Parity in Rust, another popular Ethereum client with its EVM implementation
(ethcore directory);
• cpp-ethereum, an Ethereum client that generates the consensus test suite (libevm/
VM.cpp);
Programming languages: The EVM has more than one language that compile into
it. Some of those are:
• Flint, a language with several security features: e.g. asset types with a restricted
set of atomic operations;
• Reduced cost: The cost incurred in buying and renting physical infrastructure or
virtual machines is reduced by the use of smart contracts being deployed on the network
itself.
• Improved speed: Blockchain transactions are faster and provide a better cus-
tomer experience due to the improved performance.
• Secure: The blocks in the blockchain are time-stamped for every single transac-
tion and hence are immutable but traceable. On one hand, they make the system fraud
tolerant and abuse proof while on the other, the transactions become irreversible.
• Standardization: All the points a customer earns at different places can be made
available in a single wallet and then be used at the company based on the loyalty point
provider’s policies and conditions.
Appsolutely Inc. is a universal loyalty platform that has been launched in the Philip-
pine [Agrawal et al. 2018]. The loyalty coin earned from one retailer can be used on
other brand’s purchase.
2.3 LOYALTY POINTS: BLOCKCHAIN 19
There are many more organizations that have moved to blockchain for reward-
ing. Eventually, all these corporations involve the use of digital currency. As per the
stackoverflow survey, only 12.7% of organizations use blockchain for non-currency
applications.
Chapter 3
Analysis
The analysis is a very crucial phase in any kind of development to understand the bigger
picture, the design and the requirements for the buildout. The right study of details is the
backbone of success for any project. Even in the software development life cycle(SDLC),
analysis is done before designing the application architecture and start working on its
implementation. As discussed in the introduction, this project deals with a research
question and tries to answer that by using state-of-art technology: blockchain. This
chapter emphasizes on various requirements of the project and its components to
achieve the set requirements.
If there is anything any project must have in order not to be doomed to failure, that
is a sensible and comprehensive collection of both the functional and non-functional
requirements. The major requirements that need to be fulfilled to solve the problem at
hand are discussed in the next section.
The first and most important requirement is to create an alternate currency that
acts as the backbone of the system to motivate the people to volunteer. This is fulfilled
by creating an Ethereum smart contract and deploying it on the blockchain network.
The contract should generate tokens which can be used as an award for the volunteering.
3.2 NON-FUNCTIONAL REQUIREMENTS 21
The tokens are initially assigned to one account and a certain amount can be trans-
ferred to every new organization on its successful registration. These rewards held by
the volunteering firms can then be given as credit points to volunteers. Moreover, when
redeeming these rewards in the future, the volunteers can transfer a certain amount
back to the organization and avail the required services.
The next requirement is to provide a platform where all the upcoming volunteering
activities in the country can be listed together. This is achieved by designing a web
application that can be used by the state registered volunteering organizations as well
as by the people looking for contributions to society.
This application serves the purpose of providing one-stop for all volunteering op-
portunities. Also, it comes with the convenience of maintaining one single account for
any volunteering across Ireland. Additionally, the rewards for volunteering at different
organizations are stored in one user account.
Performance: This can be measured on the statistics that the application takes few
seconds to load and the transaction of an ERC-20 token on the Ethereum platform is
confirmed within a minute on an average.
Security: The system is secure as it requires the login credentials of the user to
access their account. The user should never share the login details with others.
Moreover, the blockchain account of the user has a password that should neither
be shared nor be lost. If the password of the blockchain account is lost, it cannot be
recovered and all the credits earned are lost with it.
This application would not only require the firms to register but also the volunteers
need to enroll themselves on the system. They need to provide their basic contact
details and create a user account. An account, on one hand, will help to build trust and
confidence in the person while on the other side will enable the person to keep track of
his volunteering.
Announcing New Opportunities: Once the organizations are registered, they can
add the activities that require volunteers to come and help. This way the participants
are provided with a single platform to look for any opportunity across Ireland. The
volunteer’s account can be used to search and select from the numerous volunteering
opportunities added by various organizations on the portal.
Volunteering Requests: Besides registering, the users also need to request the orga-
nization to allow them to volunteer for a particular activity. The organization can then
accept or reject the request based on the requirement and conditions of the task.
The Ethereum blockchain allows deploying custom token on the network through
the use of smart contracts. The approach in this project is to use a token deployed on
the blockchain. This token is issued to users for the efforts in terms of hours spent in
volunteering.
Since the project also focusses on the concept of payback, the Ethereum blockchain
is the perfect platform to utilize for this functionality. Ethereum keeps a record of every
single transaction that is ever done on the network, therefore, any transaction made
to the volunteers by the organization will be recorded forever. This ensures that the
participants of volunteering can access their token anytime in the future and redeem
them for their self-care services.
3.3.3 Database
The blockchain account is used just to hold the tokens associated with a user account.
However, we have more data, other than just the tokens, that needs to be stored. The
data that needs to be stored in the database includes:
• Volunteer data: These are the details about the volunteer including information
like name, address, contact details, and the associated Ethereum address.
• Volunteering activities: This includes the description, date and time, duration
and the address of the location where volunteering is required.
Design
Designing is a very crucial step to kick start any development, especially, software prod-
ucts. It provides a clear picture of the various aspects of the system: it’s users, how will
they interact with the system or with each other and what are the various use cases
that need to be covered as part of the system architecture. This phase also helps to
understand the sequence of activities that will be performed using the application and
how this sequence will lead to solving the problem.
The Figure 4.1 is a simple use-case diagram that represents the various functionali-
ties of the system and their use by the appropriate user.
There are three actors: Volunteer, Organisation, and Admin, who will use the system
in some ways or the other. The application provides several use-case options that can
be performed by one or more users. For example, login functionality is used by all the
users of the system, whereas, the Blockchain Token Creation feature is only accessible
to the Admin.
One more thing to notice here is that the Blockchain Token Transfer function can
be called directly by the volunteer and the admin, however, for the organization, it is
included and called directly when it confirms and approves the completion of volun-
teering activity by the volunteer.
These various user activities follow a sequence to determine the interaction between
multiple entities and how the actors interact with the system. The sequence of actions
can be explained in the diagrams that follow.
• The basic functionality is the registration of users on the system. The various
steps involved in registering the different type of users are shown in Figure 4.2:
The system involves six entities: Volunteer, GUI, Database, Organisation, Admin,
Ethereum Blockchain. For registration, the organization needs approval from the admin
25
and only then it receives certain initial tokens. The system can be used by the organiza-
tion only after the admin’s approval. However, the volunteers can directly register and
create an account on the web application.
The Figure 4.3 shows a complete sequence from adding an activity by the orga-
nization to the transfer of tokens on final approval of successful volunteering. The
organizations use the front end of the application to add an activity, approve the re-
quests send by the volunteers, confirming from the person receiving the service and
then finally completing the task performed by the individual.
• The organization can also reject the request made by the volunteers.
As can be noticed in the Figure 4.4, the initial steps remain the same but the outcome
is a rejection by the organization. On confirmation from the elderly person about the
volunteering service received, the person might not have received any help or the ser-
vice might not be as expected. In that case, the organization can reject the completion
request made by the volunteer and thus, there will be no transfer of tokens from the
organization to the volunteer.
27
• The last scenario is where the initial request to volunteer is rejected by the or-
ganization. There can be any reason to it like the elderly person no more requires that
service on that day, the organization might have approved some other volunteer to
perform the task or anything similar. The sequence involved can be described as shown
in Figure 4.5
One important note here is that these diagrams represent the sequence of activities
for a single volunteering opportunity but these steps remain the same for every volun-
teering task that is added by the organization and needs efforts of the citizens in helping
the older generation to be connected to the society.
28
Implementation
This chapter discusses the project implementation as part of the thesis. The following
sections throw light on the components and technologies that were used to build the
system.
5.1 Entities
The reward system developed as part of this project is an Ethereum-based distributed
application where different users of the system interact with each other through a front-
end. The functions accessible to system entities vary from user to user.
The system is designed to identify the below three different types of users:
• Admin
• Volunteers
• Organizations
All three entities are expected to have a hexadecimal Ethereum blockchain address
before accessing the volunteering system. This address is used to send and receive the
application tokens. As mentioned earlier, ether is the fuel for any transaction on the
blockchain and, therefore, every account holder should have the right amount of ether
to enable successful function calls. The collection of ethers and tokens can only be
done through a wallet and the application designed to work with a chrome extension:
Metamask.
5.2 COMPONENTS OUTSIDE THE BLOCKCHAIN 30
5.1.1 Admin
The admin is the initial holder of all the generated tokens. When a smart contract is
deployed on the Ethereum network for token generation, the initial supply is done to
the admin’s Ethereum account. He is the token generator and distributes some fixed
amount to the organization on approval. Moreover, he can also transfer tokens to
anyone provided he has the blockchain address of the receiver. When it runs out of the
tokens, it can pay the smart contract with some ethers and get the equivalent tokens in
its account.
5.1.2 Volunteers
These are the ultimate receivers of volunteering tokens, which are stored on his/her
Ethereum wallet. The volunteers need to register themselves to use the application.
Once registered, they need to authenticate themselves every time they want to access
the system. The authentication is performed by the Firebase authenticator. Besides
this, they can transfer their earned tokens to their loved ones using the application’s
"Transfer Token" functionality.
5.1.3 Organizations
Organizations also need to enroll in the system to get the advantages. They require the
approval of admin to be a valid user of the application. Upon successful registration,
they receive certain tokens in their ethereum wallet corresponding to the blockchain
account linked to the application user account. These tokens are then transferred to the
volunteers in multiples of ten for the number of hours spent in contributing to society.
These are also responsible for announcing new volunteering opportunities. They
can also receive tokens from some users of the system and help them receive a service
by adding it to the website. This is where the basic concept of the project is achieved.
The volunteers can transfer their tokens back to the organization to receive services for
themselves.
• The front-end, the react.js web application to enable entities to perform some
tasks using the graphical user interface as well as it facilitates interaction with the smart
contract.
• Firebase database, the database platform to store details other than the tokens
as well as to support application user authentication.
Node Package Manager(NPM) is installed along with node.js on the computer and
provides thousands of free packages to use.
React.js
It enables creating interactive UIs and design state-wise views in the application.
This means that there is no need of describing transactions on interfaces but describe
the interfaces in terms of final state so that it can efficiently update and render the right
component when the data changes on the web page. React is very similar to javascript
with one small API to be learned additionally [The React Project n.d.]
Some of the basic and most important screens developed as part of the "Volunteer-
ing System" are shown in the figures that follow.
Figure 5.1 shows the summary of the token deployed on blockchain as part of the
application. It provides the details of the Ethereum address which was used to deploy
the contract on the Ethereum network, the contract address which can be used to get
the details of the smart contract, the token symbol and name, the current amount of
tokens held by the creator and also the rate at which the ethers can be converted to
"VOG" tokens.
5.2 COMPONENTS OUTSIDE THE BLOCKCHAIN 32
The volunteers can look for opportunities from multiple organisations at one place
on the "Volunteer Options" tab. The screen looks as shown in Figure 5.2. The volunteers
can just click on the "Volunteer" button to make a request to the organisation that
posted the opportunity. There can be multiple requests made at once, however there is
no option of cancelling the request once send.
Figure 5.3 shows the registration screen for the organisation. The volunteer registra-
tion screen is also the same with a few lesser fields.
5.2 COMPONENTS OUTSIDE THE BLOCKCHAIN 33
The organisation can add an activity that require helping an older person through
volunteering. The screen that allows organisation to achieve this is shown in Figure 5.4.
Web3.js
The web3.js library is a collection of modules to allow interaction with a local or
remote ethereum node [The Web3js library documentation n.d.] The web3-eth package
is used for blockchain and smart contracts. The web3 library is installed and injected
in every webpage on adding Metamask to the chrome extension. This injection helps
to get the current provider which is the basic step to fetch the ethereum address of the
"from" account. The web3.getAccounts() helps to get the hexadecimal address from
which the deduction of tokens is done while initiating a transaction.
javascript, android, and iOS. Thus, if there arises a plan of developing a mobile appli-
cation for the volunteering web app then the same database can be used on all platforms.
The database is scalable as the data can be split across multiple database instances
in the same Firebase project. Though the database offers several services, the project
uses just the two of them: authentication and database. The Firebase database can
be added to any application by just writing a few lines of configuration code in the
application. This configuration code is provided when a firebase project is created in
the Firebase console.
Authentication
Firebase Auth is a service to authenticate users using the client-side code. This
project uses this service to authenticate the various entities when they provide their
login credentials: the email id and the password, which are stored on the Firebase [Get
Started with Firebase Authentication on Websites n.d.]
From the perspective of this project, when the user registers itself on the system, a
new entry is added to Firebase authentication. The authentication tab is present under
every Firebase project created on the console. It contains details like the email id of the
user, date of account creation, last signed date and the unique user identity generated
by Firebase. A sample of the Firebase authentication for this project can be seen in the
Figure 5.5.
Realtime Database
This project uses the library written in node.js to allow web application save and
retrieve realtime data from Firebase database [Firebase Realtime Database n.d.] The
database is realtime as all the clients using a single instance of database are automat-
5.3 BLOCKCHAIN COMPONENTS FOR SMART CONTRACT 36
ically updated when any changes are made in the data. It is used to store all sorts of
data that need not be stored on the blockchain, such as volunteer details, organization
details, admin data, volunteering opportunities, requests made by the volunteers.
The data for the project is stored in a project named as "VOGen". The various
records can be stored under respective collections as shown in Figure 5.6.
Ropsten, on the other hand, is more similar to the main net as it uses proof-of-work
consensus. Though it is similar to the mainnet, the mining is weak which makes it
slower than the Rinkeby network. Additionally, mining on Ropsten is done just for the
developer community and there is no financial incentive given to the miners. The gas
fee paid for processing a transaction on any test net is very low compared to a real
blockchain transaction.
5.3.2 Metamask
It is a bridge that allows visiting the distributed web using the browser. It is a great
tool for developing Ethereum DApp without running a full Ethereum node. Metamask
has a secure identity vault that enables users to manage multiple identities on various
websites to sign blockchain transactions.
Metamask add-on can be installed on different browsers like Chrome, Firefox, Opera
and even Brave browser [Metamask Project n.d.] In November 2018, MetaMask’s Google
Chrome browser extension surpassed 1.3 million users [Rhodes 2019]. In this project,
the Metamask is installed as a chrome extension. The figures below show the Metamask
interface of the admin account. The various details displayed on the interface can be
described as:
• The network, that is, the Rinkeby Testnet on which transactions are done. How-
ever, the dropdown has the option to select any of the other available networks as can
been seen in the Figure 5.7.
• The most recent transaction done by the admin in Figure 5.8 is the creation of
volunteering tokens in exchange for 1Ether.
• The second last transaction was the transfer of tokens. The transaction was
successful.
• The Figure 5.7 also shows a transaction, that is, transaction number #32 which
was failed either because it was canceled by the sender(admin) or the gas fee was insuf-
ficient to pay for the transaction.
sites. The extension automatically injects web3 API into every webpage’s javascript
context. In this project, this API injection helps the web application to read from and
write on the smart contract deployed on the Rinkeby network. It provides a personal
wallet to store the credits earned by each user.
Since Metamask allows creating multiple accounts, this project uses it to create vari-
ous personal wallets for admin, organizations, and volunteers. The main of Metamask
is to make Ethereum as easy to use for as many people as possible.
5.3.3 Etherscan
Etherscan is a web application used for in-depth inspection of every single transaction
done on the network. Not only does the Ethereum main net has its own Etherscan to
inspect the transactions but also the test networks: Rinkeby, Ropsten, and Kovan [Ether-
scan Project n.d.] The Figure 5.9 shows the list of all the transactions that are done with
the smart contract used in the volunteering system project.
The Figure 5.9 also has the "Token Tracker" which explains that the token is created
in the name "VOGen Coin" and uses the symbol "VOG" to represent itself. Besides this,
it also provides the "creator address" 0x80d6668DF50852... which is also the ethereum
blockchain address of the admin. This symbolizes that the admin is the creator of the
contract.
5.4 Tokens
A token is a currency used in the Ethereum volunteering system to reward volunteering
and motivate people to volunteer even more. Ethereum uses ethers as its cryptocurrency,
however, the points value in the system is extremely low concerning ethers(1 ETH = 1018
tokens). This concludes that Ethereum not only has a currency of its own but also have
tokens on top of it, which can act as a currency [Ethereum Blockchain n.d.]
Metaphorically, Ethereum can be seen as the internet and all the DApps as the
websites that run on it. DApps are decentralized and owned by people once the related
smart contract is deployed on the Ethereum platform. Therefore, people need to own a
certain number of tokens to take complete advantage of the system. It must be specified
here that tokens might not be the need of every DApp, it depends on the context of the
application. In this project, tokens are used as credits for volunteering.
Since Ethereum has ethers as its currency then why not use ethers directly for trans-
actions? What is the need for an alternative currency? The answer to these questions
lies in the real world where there is a ticket system considered over directly using money,
even though the tickets are bought using money.
The most common and used standard for designing Ethereum tokens is ERC-20.
ERC-20 Standard
ERC-20 is a technical standard that defines a certain set of functions that the devel-
opers can use for smart contract deployment on Ethereum blockchain. The majority
of tokens on Ethereum are ERC-20 compliant. There is no enforced rule to implement
ERC-20 standards in the tokens but having them ensures that the tokens can undergo
interactions between various wallets, exchanges, and smart contracts without any issue.
According to Etherscan.io, there were 200,778 ERC-20 token contracts on the Ethereum
blockchain as on July 16, 2019. For a token to be ERC-20 compliant, it needs to declare
some variables and a set of six functions that can be recognized by other smart contracts.
The following activities are the basic ones that need to executed by every ERC-20 token:
All the four functions mentioned are used in the token creation in this project. The
transfer token uses the receiver address and the value to be transferred.
The points transfer in the volunteering system stands for transferring tokens from a
sender to a receiver. There are following four use-cases which involve token transfer:
• Volunteers transferring tokens to their loved oldies so that they can use the
tokens to receive volunteering services.
In the first two cases, the transfer of tokens takes place internally when a request
approval is done by the user, that is when the admin approves an organization or the
organization approves the volunteering effort of a volunteer.
Figure 5.10 shows the "Completion Request" page of the organisation where the
organisation can approve or reject the request from the volunteer. The transfer of tokens
from organisation’s Ethereum account to volunteer’s account takes place on clicking
the "Approve" button. This also completes the request cycle by marking its status as
"Completed". The organisation can click on the "Reject" button and there is no transfer
of token.
In the last two cases, the transfer operation is performed by filling in a form, as
shown in Figure 5.11. This form has two fields which require the receiver address and
the token value to be transferred. On clicking the "Transfer" button, the transfer of to-
kens from the logged-in user’s account (Admin/Volunteer) to the account of the receiver
is initiated.
Once all the checks by the Metamask are successful and the transaction also passes
all the validations mentioned in the smart contract, the logged in user can see the suc-
cess message on the screen as shown below in Figure 5.13.
This chapter focusses on the testing of the volunteering system and evaluate the results
achieved on the completion of the project.
6.1 Testing
For any project, testing is required to ensure that the requirements are fulfilled by the
system and it behaves as expected. This system is build in modules and there are various
types of testing being performed. A few of those are explained below:
Thereafter, the connection call to the Ethereum smart contract is done by calling the
Metamask and the web3 injected in the browser. The web application is verified to call
6.2 CHALLENGES 46
Metamask extension and make successful transfer of tokens to the receiver’s account.
6.2 Challenges
While developing the prototype application there were certain challenges faced at the
technical front. The integration of various modules need to be synchronised to ensure
the system works as per the desired behaviour. Some issues are discussed as below:
• Proper addition of the Metamask plugin to chrome extension: If the plugin is not
installed properly, the application would not be able to fetch the ethereum address of
the user logged in to the application and gives the error as shown in Figure 6.1. This
ethereum address is the from address to make any transfer of tokens.
• Web3 integration: The web3 integration is a must to make the web application
communicate with the Ethereum network. The inappropriate version or improper call-
ing of web3 library leads to issues such as transaction failure on blockchain.
6.3 EVALUATION 47
6.3 Evaluation
The evaluation of the work is done based on below-mentioned parameters:
• Reviews from society on the project, like will the people be willing to use the
application.
6.3.1 Performance
The time required to mine a transaction and add it to the Ethereum blockchain network
depends on the amount of gas paid as well as the network congestion. On an average day,
every transaction on the Ethereum network takes 15 seconds to 10 minutes for mining,
provided that, a standard gas price is paid. A decrease or increase in the standard gas
price for a transaction can slow down or speed up the transaction respectively. This
project has observed many variations in the time when provided a higher gas for faster
processing.
6.3.2 Cost
The only cost involved in the transfer of tokens is the gas fee that fuels the transaction.
Higher the gas price, the higher is the chance of the transaction to be picked by miners.
For this project, the gas price was set to a low value: 1gwei, which coincides with the
lowest safe value. The transaction fee for a different type of transaction varies, however,
it is the same for all similar transactions.
The gas price of the transaction to transfer tokens from sender to receiver is 39,514
gwei, which is equal to 0.0075USD; it must be noticed here that the amount of tokens
transferred does not affect the gas price paid. The gas price is affected when the sender
is willing to pay more for a faster transaction and increases the gas fee manually.
Business Perspective
This project is done in collaboration with the Independent Living Ireland(ILI) or-
ganisation. The organisation’s representative, Patrick Mulvihill, not only helped in
understanding the requirements but also shared his insight on the work. According to
Patrick, the application could add value to the work that ILI have put into developing a
6.3 EVALUATION 48
General Survey
As the project work is done with the motive of making a change in the society, it is
important to understand what the community feels about the application and how will-
ing are they to use it in future if the application is launched in complete sense. For this
purpose, there was survey done which included five people in the age group 20-35years.
The survey was kept short and quick as it also involved showing the application to the
people. The questions prepared for the survey are:
• Q3: How about earning blockchain tokens as reward points and use them in
your retirement to receive services?
• Q4: Would you register and use a system like the "Volunteering System" if it is
available in future?
• Q5: What according to you is the most interesting feature of the prototype appli-
cation?
Payal Naik(25years)
She does not volunteer as she’s always occupied with work or studies. However, she
feels that if volunteering can earn her something she would definitely start devoting
her time for some activity. Moreover, the idea of blockchain fascinates her as it is a new
buzzing technology. Payal on having a walkthrough of the prototype application feels
that she would surely use the application if it’s available. Lastly, she finds the use of
blockchain tokens as the most interesting feature as its long lasting.
David O’Shea(34years)
David works for construction department and has a family. He used to volunteer
in his teen age but ever since he started working and that he has a family now, he finds
difficult to get time to volunteer. He thinks having a reward system to help elder people
is a great idea and he too would like to volunteer and earn blockchain tokens. An experi-
ence of the prototype application helped him to understand various uses of the system
and he would wait for a system like this to be available. The concept of transferring
tokens to loved ones was most appreciated by David as he feels he can share his tokens
6.3 EVALUATION 49
Rachel (31years)
• Ans3: I do not have much idea about blockchain but if I earn something that I
can use in my old age, I will definitely volunteer and earn.
• Ans5: The payback system is well thought and something that encourages me to
use the application as today I’m capable to volunteer and secure my old age to receive
services.
Anmol Vaish(26years)
John McCarthy(28years)
John is already involved in a lot of volunteering but he still finds the idea of the
project as relevant to the need of society in current times. He believes that this con-
cept of using blockchain tokens will encourage him and other like-minded people to
contribute more to the elderly people. The application is a platform that combines
all volunteering opportunities across Ireland which will allow him to volunteer even
when he’s travelling to different part of the country. A single user account for all the
organisations is the best to keep track of all the good work done.
These results of the survey gives the confidence that the application will be helpful
to society for some or the other services that it provides.
Chapter 7
Final Conclusion
This research was aimed to solve the issues of the volunteering sector in Ireland by the
use of technology. The objective has been achieved by designing a prototype applica-
tion that uses the basic concept of loyalty points by storing those e arned points on a
blockchain platform ensuring the tokens last forever and cannot be tampered.
In my opinion, blockchain technology has a great reach and will improve security,
increase speed, and save money. The immutability of the transactions enables its adop-
tion in many sectors like government and medical records-keeping where the data once
stored is not changed. Though blockchain technology has found its way into many
organizations it still has a long way to penetrate the mindsets of people, just like the
internet technology.
Many other aspects could also be realized but remained out of scope due to the
51
time constraint of the project. There could have been discussions and workshops with
the volunteering organizations in Ireland to better understand the improvements that
might have been made on the existing prototype development.
As part of the future scope, the prototype can be transformed to a complete applica-
tion available to the society. Also, there can be mobile applications developed on the
same concept for the ease of the volunteers to look for opportunities and earn credits
after successful volunteering. Besides this, the geographical reach of the application
and concept can be expanded as the system does not rely on one currency which is
continental.
Appendix A
Developer’s Manual
This appendix details the most important part of the code written as part of the thesis.
It briefs about the smart contract, database configuration and web3.js configuration.
0x4b5C007Aa29C61B63dAd684c731bd8a5e62997F5
• SafeMath Library
• IERC20 Standard
• Owner restrictions
A.1.1 SafeMath
This is an OpenZeppelin library to ensure safe math operation by throwing errors. Cur-
rently this library is used in almost every smart contract as it provides protection against
underflows and overflows. The related code is shown in Figure A.1
A.1 VOGEN SMART CONTRACT 53
A.1.2 IERC20
This library is used to ensure that the token created by deploying the smart contract is
ERC20 compliant. The interface in Figure A.2 represents some of the functions to make
the token ERC20 compatible.
These two lines of code define the contract and also simultaneously declare the
contract imports token interface, safeMath library and owner restrictions.
The main modules managed by the contract are: token creation and transfer of
tokens.
Token Creation
After the parameters are declared and defined, the ERC20 functions needs to be
declared and implemented.The functions totalSupply() and balanceOf(address account)
just returns the value of the variables totalSupply and balances[account], like two stan-
A.2 WEB3 55
dard getters.
The most interesting and useful function from the point of this project is the trans-
fer() which is the key function to transfer tokens and takes the parameters as below:
This function can be implemented as in Figure A.4. The comments in the code
snippet explains the use and function of every line of code.
A.2 Web3
Web3.js is imported and linked to the Ethereum Rinkeby network using the code in the
Figure A.5. The code checks if the Metamask plugin is installed and web3 is injected to
the web pages running on the browser.
Agrawal, Dhwani et al. [2018]. “Loyalty Points on the Blockchain”. In: Available
at SSRN 3246395.
Blockchain: how mining works and transactions are processed [May 2, 2018]. URL:
https://blog.goodaudience.com/how-a-miner-adds-transactions-
to-the-blockchain-in-seven-steps-856053271476.
BlockchainHub [n.d.] Blockchains & Distributed Ledger Technologies. URL:
https://blockchainhub.net/blockchains-and-distributed-ledger-
technologies-in-general/.
Buterin, Vitalik [Aug. 6, 2015]. On Public and Private Blockchains. URL: https:
/ / blog . ethereum . org / 2015 / 08 / 07 / on - public - and - private -
blockchains/.
Chinchilla, Chris [June 17, 2019]. Ethereum white paper. Tech. rep. URL: https:
//github.com/ethereum/wiki/wiki/White-Paper.
Ethereum Blockchain [n.d.] URL: https://www.ethereum.org/.
Etherscan Project [n.d.] URL: https://etherscan.io/.
Feliam [Oct. 30, 2018]. The Ethereum EVM Implementations. URL: https :
//github.com/ethereum/wiki/wiki/Ethereum- Virtual- Machine-
(EVM)-Awesome-List#evm-implementations.
Firebase Realtime Database [n.d.] URL: https : / / firebase . google . com /
docs/database/.
Get Started with Firebase Authentication on Websites [n.d.] URL: https : / /
firebase.google.com/docs/auth/web/start.
Hayashi, Mayumi [2012]. “Japan Fureai Kippu time-banking in elderly care:
origins, development, challenges and impact”. In: International Journal of
Community Currency Research 16.A.
Loon, Preston Van [n.d.] Ethereum 2.0 Phase 0 Testnet Release. Ed. by Medium
Corporation. URL: https://medium.com/prysmatic-labs/ethereum-2-
0-phase-0-testnet-release-1e9e682db910.
Making blockchain real for customer loyalty rewards programs [n.d.] Deloitte.
URL : https://www2.deloitte.com/us/en/pages/financial-services/
BIBLIOGRAPHY 58