Real-life Application of a Decentralized System

Page 1

ISSN: 2395 0056

ISSN: 2395 0072

Real-life Application of a Decentralized System

1,2UG Student, Dept. Of Information Technology, Narsee Monjee College, Mumbai, Maharashtra, India

3Assistant Professor, Dept. Of Information Technology, Narsee Monjee College, Mumbai, Maharashtra, India

Abstract Blockchain is the technology that can lead to significant changes in our current technology andwillhave a great impact on the next few decades. It can change the way we perceive technological processes, and can also transform our economy. The majority of current Blockchain Technology research is focused on its application for cryptocurrencies such as Bitcoin and Ethereum, with only a few studies looking at the use of Blockchain Technology in other settings or sectors. Blockchain Technology is more than just cryptocurrency, it can have several applications in governmental activities, finance and banking industries, accounting, and many business processes. Therefore, this paper aims to explain how Blockchain technology works, demonstrate its real world application by looking into the current lottery picking system, and propose an E lottery picking system using smart contracts in the Blockchain ecosystem, as well as how it can be deployed on the Ethereum Network.

Key Words: Blockchain, Decentralization, Smart Contract, Token, Solidity

1. SYSTEM FUNDAMENTALS

1.1 Blockchain Technology

Blockchain,alsoknownasDistributedLedgerTechnology (DLT),makesthehistoryofanydigitalassetimmutableand transparentbyutilizingdecentralizationandcryptographic hashing.

ThethreekeycomponentsofblockchainareBlocks,Nodes, andMiners.

1.1.1 Blocks

Blockchain is essentiallya chain of blocks, each of which containsthethreepiecesofinformationlistedbelow:

Thedatastoredintheblock.

Thenonceisa32 bitwholenumber.Whenanewblock iscreated,acompletelyrandomnonceisgenerated, whichthengeneratesablockheaderhash.

Thenonceisrelatedtothehash,whichisa256 bitvalue. Ithastostartwithalotofzeros(i.e.,itmustbeextremely small).Anoncegeneratesthecryptographichashwhenthe first block of a chain is created. The data in the block is regardedsignedandirreversiblyconnected tothenonce andhashunlessitismined.

1.1.2 Miners

Minersuseatechniqueknownasminingtoinsertfresh blockstothechain.Everyblockinablockchainhasitsown unique nonceandhash, butitalsorefersto the previous block'shash,attemptingtomakeminingablockdifficult, particularly on large chains. Miners employ specialized methodstosolvetheenormouslydifficultmathproblemof producingavalidhashusinganonce.Becausethenonceis only32bitslongandthehashis256bitslong,thereare roughly four billion nonce hash combinations to mine. Whenthishappens,minersaresaidtohavestumbledupon the"goldennonce,"andtheirblockisaddedtothechain.

Changinganypreviousblockinthechainnecessitatesre mining not only the damaged block, but all subsequent blocks as well. As a result, manipulating blockchain technology is extremely difficult. Consider it "safety in math," because identifying golden nonces requires a significantamountoftimeandcomputationalabilities.

Whenevera block issuccessfullydugup,all nodesinthe network recognize the alteration, and the miner is financiallyrewarded.

1.1.3 Nodes

One of the most fundamental concepts in blockchain technology is decentralization. A single machine or Organizationcannotownormanipulatethechain.Instead, the nodes that connect to the chain create a distributed ledger.Anodeisanytypeofelectronic devicethatsaves copies oftheblockchainandkeepsthenetwork running. Eachnodehasitsowncopyoftheblockchain,andinorder for the chain to be updated, trusted, and confirmed, the network should algorithmically approve any new mined block. Because blockchain are transparent, every transaction in the ledger can be easily reviewed and investigated. Each participant is given a unique alphanumeric identification number that is used to keep trackoftheirtransactions.

1.2 Dapps (Decentralized Applications)

The issue of privacy and security has been of utmost importance in the last decade for consumers and businesses alike, as more users are being aware of their rights,businessesneedtobemorecautiousabouthandling

International Research Journal of Engineering and Technology (IRJET) e
Volume: 09 Issue: 04 | Apr 2022 www.irjet.net p
© 2022, IRJET | Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal | Page663
PARTHIV JANI1 , ASHMIT SRIVASTAVA2 , ANUPAMA JAWALE3
***

of Engineering and Technology (IRJET)

Volume: 09 Issue: 04 | Apr 2022 www.irjet.net

their user’s data. Let’s see a brief history of various technologiesusedtoensureprivacyandsecurity.

The concept of cryptography was first used in 1900 BC in Egypt.Sincethenithasbecomeanessentialtoolinthearsenal of computer scientists and mathematicians to design robust systemswhicharesecureandcannotbecompromisedvery easily. From the password of your Google account to the messagesyousendonWhatsApp,everythingisencrypted,so onlythosewiththeencryptionkeycanseethem.

But when we talk about privacy, we are not always talking about a data breach or a hack, we also talk about the companies that are responsible for encrypting andhandling thisdata,allthesecompaniesexploitthegathereddatainsome ortheotherway.

That’swhendecentralizationcomesintoplay,24yearsafter theblockchainwasinventedin1991,In2015,VitalikButerin invented Ethereum which gave birth to decentralization. Decentralizationasthewordimpliesisa terminologythatis usedtodescribeasystemwhichisnotcontrolledbyanysingle entity.Itiscontrolledbyanyoneandeveryonewhoisthepart ofthatsystemfore.g. ifanapplikeFacebookisdecentralized, thenallthedataofalltheusers,willbestoredinthebillionsof devicesthatareusingFacebook insteadofa singleserveror theserversofacompany,onlytheuserwhoownthatdatacan accessthatdataandeachofthosebillionsofdevicesiscalleda node.

They have a slightly different architectureas compared to a traditionalapp.Thecompletearchitecturewillbediscussedin theprojectindetail.

e ISSN: 2395 0056

p ISSN: 2395 0072

AlotterysystemisperfectusecasefordesigningaDAppas usersneedtohavetrustonsomeperson/companytotakepart inalottery,aDAppcanbedesignedasa transparentlottery systeminwhichallthedataandmoneywillbestoredonthe blockchain till the time a winner is announcedand then the moneywillbesecurelysenttothewinner.

1.3 Ethereum Network

Ethereumisadecentralized,opensourceblockchainwithsmart contractfunctionality.Etheristhenativecryptocurrencyofthe platform.AfterBitcoin,bymarketcapitalization,itisthemost valuablecryptocurrency.TheEthereumblockchainisthemost widelyutilizedblockchain.

VitalikButerin,aprogrammer,presentedEthereumin2013. Crowdfundingwasusedtosupportdevelopmentin2014,and thenetworkstartedoperatingonJuly30,2015.Developerscan use the platform to deploy permanent and immutable decentralisedapplicationswithwhichuserscaninteract.

Itisanetworkmanagementprotocolthatallowsuserstobuild and execute smart contracts on a decentralised network.A smart contract is made up of code that performsspecific operationsandcommunicateswithothersmartcontracts,and itmustbewrittenbyadeveloper.IncomparisontoBitcoin, whichstoresnumbers,Ethereumstoresexecutablecode.

With their ability to decentralise information and services, EthereumDAppsprovideaplatformforWeb3.0tosupplya totally free (as in freedom) and accessible Internet for everybody.Becausetherewillbenomiddlementofacilitatethe flowofinformationandservices,therewillbenoneed fora centralpointofcontrol.

Ethereum is a permission free, non hierarchical group of networks (nodes) that construct and find consensus on an ever growingseriesof"blocks,"orbatchesoftransactiondata, knownastheblockchain.Eachblockcontainsanidentifierfor theblockthatitmustimmediatelyfollowinthechaininorder tobevalid.Wheneveranodeintroducesablocktoitschain,it implements the transaction records inthe order they were added,causing theETH balances andother storage values of Ethereumaccountstochange.Thesebalancesandvalues,known collectivelyasthestate,arekeptseparatefromtheblockchain onthenode'scomputerinaMerkletree.

1.4 Smart Contract

SmartContractsarethemostessentialbuildingblocksofour applicationwhichenablesustocodeourbusinesslogicandour in game crypto currency into a piece of code whichis then deployedontoapublicblockchainnetwork.Solidityisthename of the programming language which is used to create this smartcontract.Therewillbetwosmartcontractsthatwillbe usedonourlotteryapplication.

9001:2008

TheappswhicharedecentralizedarecalledDApps.
International Research Journal
© 2022, IRJET | Impact Factor value: 7.529 | ISO
Certified Journal | Page664

of Engineering and Technology (IRJET)

Volume: 09 Issue: 04 | Apr 2022 www.irjet.net

TokenSmartContract

Thissmartcontractisusedtocreatethecurrencythatwill be used in the lottery game. It will be an Ethereum token following the ERC20 standard and will be deployed separatelyontheblockchainnetwork.Thiswillspecifyallthe functionalities ofour in gamecurrency.Fromthecurrency nametoitssupplyetc.Thiscontractusessoliditylanguage.

LotterySmartContract

This smart contract consists of the business logic of our application,thelogicbehindpickingthelotterywinner,the logicofacceptingthefundsandstoringitinthecontract,the logicoftransferringfundswhenawinnerisdeclared. This will be implemented separately from the token smart contract on the Ethereum network. For development and debugging, this contract additionally employs the Solidity programminglanguageandtheRemixIDE.

1.5 Solidity Language

Solidityisanobject orientedprogramminglanguageusedto create smart contracts. It is used to implement smart contracts on various blockchain platforms, the most prominentofwhichisEthereum.ItwascreatedbyChristian Reitwiessner,AlexBeregszaszi,andseveralformerEthereum corecontributorstoallowthecreationofsmartcontractson blockchain platforms like Ethereum.The Solidity compiled programs are designed to run on the Ethereum Virtual Machine.

Solidity is an object oriented, high level programming languageusedtoimplementsmartcontracts.Smartcontracts are programs that govern how accounts behave in the Ethereumstate.

Solidity is written in curly brackets. It is inspired by C++, Python, and JavaScript and is intended for use with the EthereumVirtualMachine(EVM).

Solidityisstaticallytypedand,amongotherthings,supports inheritance, libraries, and complex user defined types. Soliditymakesitpossibletocreatecontractsforthingslike casting a vote, crowdfunding, blind auctions, and multi signaturewallets.

2. ISSUE WITH CURRENT LOTTERY SYSTEM

Thekeyissueintheexistinglotterysystemsisthatthewhole processisveryvulnerabletovariouskindsofscams,frauds, and other attacks; and to participate in a lottery, a person musthavesomeleveloftrust.Theconstitutionallawsrelated tothesetypes ofsystemsareveryambiguousandareeasily exploited,allthesemayleadtolossofmoney,identitytheft, lossofprivacyetc.

Factor value:

e ISSN: 2395 0056

p ISSN: 2395 0072

The overall problem can be further categorized into various aspects such as lack of privacy, the requirement of trust, possibilityoftechnicalfailures,lackof accessibility,unclear procedures,longwaittimes,orsometimenopaymentatall.

Takingpartinalotteryusuallyentailsobtainingaphysical lottery ticket with a serial number imprinted on it from a store,andthenwaitingforthewinningserialnumbertobe announcedandcomparingittoyourstoseeifyouhavewon anything.Thewholeprocessispronetohumanerrors,from misplacing the serial number to not matching the serial numbercorrectly;therearemanythingsthatcangowrongin suchasystem.Ifit’sanonlinelottery,manyoftheissuesgets resolvedbutnewonesalsoarisesuchaslackofprivacy,you needtoprovideyourdetailsalongwithyourpaymentmethod detailstopurchaseaticket,thepossibilityofitbeingascam etc.

All these problems need to be tackled if we want to democratizethewholeprocessoftakingpartinalotteryand tryourluckwithoutworryingaboutthetrivialstuff.

3. PROPOSED SYSTEM

Removal of the need to trust and increased privacy and robustnessthroughoutthewholeprocessoftakingpartina lotteryisthemaingoaloftheproposedsystem.

Theuseofblockchaincanhelpusachieveallthesedesired goals in a very efficient manner, use of blockchain is synonymous with privacy and anonymity and the overall rulesandregulationsgoverningsucha lotteryissystemis availableinthepublicdomainasallthecodewrittenhastobe deployedonapublicblockchainlikeEthereum,cardanoetc.

Blockchainalsodoesthejobremovingmostofthetechnical issues such as risk of hacking, loss of credentials, identity theftetc.Thesmartcontractwrittentomanagethelottery systemmakessurethatthereisnounauthorizedaccessto the funds at any point of time and all the winnings are automatically transferred to the winner after the lottery manager has executed the function which picks a random personfromthepoolofparticipants.

The transfer of payments is done in the form of a cryptocurrency so that the privacy and anonymity of the participantismaintainedandthetransactionisimmutable whichmeansthatthereversaloftransactionisimpossible.

The front end of this system which is built in react is responsiveandveryintuitive.Theback endofthissystem canalsobeusedtobuildamobile app,desktopapporany othertypeofappforanyotherplatform.

Morefeaturescanbeaddedlater,suchastheabilityto withdraw your money from the lottery, or ability to run multiplelotteriesatonetimeetc.

9001:2008

International Research Journal
© 2022, IRJET | Impact
7.529 | ISO
Certified Journal | Page665

Technology (IRJET)

e ISSN: 2395 0056

Volume:

4. WORKING OF THE SYSTEM

Architecture Flowchart

Chart-1:

Application

Chart 2:WorkingoftheSystem

4.2 Flowchart Explanation

Thearchitectureofourdecentralizedapplicationisexplained throughabovediagram:

There are two separate smart contracts namely Lottery Contract and ERC20 Contract deployed on the Ethereum blockchain network. The React server is responsible for servingtheweb pagetotheclientandalsointeractingwith the deployed lottery contract to fetch the list of players, addinganewplayerandenablingthemanagertoexecutethe pickWInnerfunction.Thelotterycontracttheninteractswith theERC20 smartcontractfortransferoffunds,gettingthe totalbalanceofanaddress,sendingsometoken toanother address.Thereactweb pagealsocontainsinjectedweb3which means that we allow Metamask to take control of all the blockchainintegration.Thisenablesustooffloadabunchof taskstometasmask.Thingslikegasfeescalculation,account management and integration with various API’s are taken careof.

p ISSN: 2395 0072

The2nddiagramexplainstheworkingofthesystem.

Suppose, there are two people who went to our lottery websiteandtookpartinitbypayingsometokenamount.So theenterLotteryfunctionwilladdthemtotheplayersarray. Now let’s say the pickWinner function is executed bythe contractmanager,basedontherandomnumbergenerator, andeitherofthemhasanequalchanceofwinningthelottery. Letussayplayer1wonthelottery,then,thecombinedtoken amountofplayer1andplayer2will besenttoplayer1ashis winnings

4.3 Code

pragmasolidity>=0.4.22<0.9.0;import'./ERCToken.sol'; contractLottery{

stringpublicname='LotteryContract';ERCTokenpublic ERCtoken; addresspublicmanager;address[]publicplayers;uint256 totalMoney=0; constructor(ERCToken_ERCtoken){ ERCtoken=_ERCtoken;manager=msg.sender; } modifier restriction(){ require(msg.sender==manager); _; }

function enterLottery(uint _amount) public { require(_amount==100000000000000000000); ERCtoken.transferFrom(msg.sender, address(this) , _amount); players.push(msg.sender); totalMoney = totalMoney + _amount; } function random() private view returns (uint){return uint(keccak256(abi.encodePacked(block.di fficulty,block.timestamp,players))); }

function pickWinner() public restriction{require(players.length >0);

uint index = random() % players.length; ERCtoken.transfer(players[index],totalMoney);

}

function getPlayers() public view returns(address[] memory){ returnplayers;

International Research Journal of Engineering and
09 Issue: 04 | Apr 2022 www.irjet.net
© 2022, IRJET | Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal | Page666
4.1
Architecture of Decentralized

4.4 Key Function Explanation

The constructor functions accept the address of the deployedECR20tokentoinitiatethelotterycontract.

Theenterlotteryfunctionaccepts100tokensfromthe sender account and the respective sender’s address to playersarrays.

In solidity, the random function is used to generate a pseudorandomnumber.

ThepickWinnerfunctionisusedtoexecutethewinner picking logic of the Lottery. This function can only be executedbythemanagerofthelotterycontract.

The getPlayers() function is used to get the list of addresseswhicharepartoftheplayersarray.

5. Benefits of Using Proposed System

Nosinglepointoffailure:

Unlikeatraditionalweb appwherethereisusuallyasingle pointoffailurelikeawebserver,adecentralizedapphasno singlepointoffailureasitrunsonablockchainwhichhasa greatnumberofnodesallaroundtheworld.

Transparency:

ThecompletecodefortheERC20tokenaswellasthelottery systemisdeployedona public blockchainnetwork soany personcanhavealookatitanddecideforthemselvesbefore usingthesystem.

Security:

Ablockchainsystemisvirtuallyhack proofasthecomputing resources required to manipulate a blockchain system is exponentially higher than the most powerful computeron thisplanet.

Privacy:

Thelotteryparticipant'sidentityiskeptsecretatalltimes; onlythepublickeyisdisplayed,whichcannotbetracedback totheownerinanyway.

Decentralized:

As the application is completely decentralized, no single entityhasanykindofaccesstoanykindofdata.

Blockproof:

DAppsaren'trestrictedtoasingleIPaddress.Itisfarmore difficultforexternalauthoritiestostopaDAppbecausethere islessauthorityowningtheDApp'snetwork.

6. CONCLUSION

In this paper, we develop a token and a lottery system to demonstrate a blockchain system based decentralized applicationwhichsolvesseveralissuesthatpeoplearefacing with current lottery games and systems. This paper introduces a new methodology using Smart Contract and Ethereumnetworkintheprocessof selling andpurchasing lottery tickets. Thissystemwillreplacetheoriginallottery operations in every aspect such as the removal of third partiesinthebuyingprocess, ensuringtheefficiencyinprize declarationandtheclaimingofprizes.Theproposedlottery system can ensure that the system is working with all fairness,transparency,andsecurity.

Withthehelpofthisapplication,itisshownthatBlockchainis notjustaboutcryptocurrencyandithasalotofreal world applicationsthatcanhelpinsolvingmajortrustandsecurity issues.

Fig 2: Lottery Contract Deployment with address. Fig-1: Token Contract Deployment with address.
International Research Journal of Engineering and Technology (IRJET) e ISSN: 2395 0056 Volume: 09 Issue: 04 | Apr 2022 www.irjet.net p ISSN: 2395 0072 © 2022, IRJET | Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal | Page667

International Research Journal of Engineering and Technology (IRJET)

Volume: 09 Issue: 04 | Apr 2022 www.irjet.net

REFERENCES

[1] Vitalik Buterin et al. 2014. A next generation smart contractanddecentralizedapplicationplatform.whitepaper (2014)

[2] Vitalik Buterin et al. 2013. Ethereum white paper. GitHubrepository(2013).

[3] Nakamoto, S. (2008) Bitcoin: A Peer to Peer ElectronicCashSystem.https://bitcoin.org/bitcoin.pdf

[4] Chris Dannen. 2017. Solidity Programming. InIntroducingEthereumandSolidity.Springer

[5]NSzabo.1997.Nick Szabo theidea ofsmartcontracts. Nick Szabo's Papers and Concise Tutorials. http://szabo.best.vwh.net/smart_contracts_idea.html(1997).

[6]PlayDapp(August2019)WhitePaper_v1.0

ISO 9001:2008

e ISSN: 2395 0056

p ISSN: 2395 0072

© 2022, IRJET | Impact Factor value: 7.529 |
Certified Journal | Page668

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.