Thisprojectprovidesaverysimplestarterapplicationforworkingwithweb3jandthetestEthereumnetwork(testnet)knownasRinkeby.
Thedemodeploysahelloworldsmartcontractwhichcontainsagreetingmessage.Thecurrentgreetingmessagecanbereadandmodifiedinthesmartcontract.
Inordertorunthisdemo,threepiecesofinformationarerequired:
Ethereumclient(ornode)endpoint.ThesimplestthingtodoisrequestafreeaccesstokenfromInfura.Awalletfile.ThiscanbegeneratedusingtheEpirusCLI.SomeEther.ThiscanberequestedfromtheRinkebyFaucet.OncethesedetailshavebeenaddedtothemainApplicationclass,you'llbegoodtogo.
FunctionalityThisapplicationdemonstratesanumberofcorefeaturesofweb3jandEthereum:
ConnectingtoanodeontheEthereumnetworkLoadinganEthereumwalletfileSendingEtherfromoneaddresstoanotherDeployingasmartcontracttothenetworkReadingavaluefromthedeployedsmartcontractUpdatingavalueinthedeployedsmartcontractViewinganeventloggedbythesmartcontractBackgroundThisapplicationhaspurposefullybeenkeptassimpleaspossiblewiththeaimofdemonstratinghowtodeployandworkwithasmartcontractonthedecentralisedEthereumnetwork.
Ifyourequirefurtherbackgroundinformationabouttheaboveconfigurationitemsfortheprojectyoucanrefertothebelow.
Foramorecomprehensiveoverview,IrecommendyoureadtheJavaMagazineArticle,watchtheYouTubetalk,andreadallofthedocumentation.
SmartcontractsThecontainedsmartcontractisbasedontheGreetercontractexample,withtheadditionthatthevaluestoredintheGreetercanbemodified.
TheassociatedJavasmartcontractwrapperisnamedGreeter.
Formorebackgroundonsmartcontracts,refertothesmartcontractssectionofthedocs.
InfuraIfyoudon'twanttosignuptoInfura,andwouldliketorunanodeyourself,thereareinstructionsinthegettingstartedsectionofthedocs.
TestnetsFormoreinformationonthedifferentEthereumtestnetworks(ortestnets),refertothetestnetoverviewinthedocs.
EtherForbackgroundonEther,refertothetransactionsoverviewsectionofthedocs.
WalletsandtransactionsigningForamoretechnicaloverviewofworkingwithwalletfiles,refertotheOfflinetransactionsigningsectionofthedocs.
ViewingrequestsAlogbackconfigurationisincludedintheprojectdependenciesallowingtheloggingofprotocolmessagesifrequired.Toenable,simplychangethefollowinglineinthelogbackconfigurationtoread:
<loggername="org.web3j.protocol"level="DEBUG"/>
评论