Lightweight and idiomatic Scala wrapper around Web3J for Ethereum.
May 8, 2020: I have abandoned this project and will not update it. If someone else wants to take it over please contact me.
-- Mike
web3j-scala
is an idiomatic Scala wrapper around Web3J for Ethereum.
Web3J is a lightweight, reactive, somewhat type safe Java and Android library for integrating with nodes on Ethereum blockchains.
Web3J features RxJava extensions, and web3j-scala
wraps that syntax in Scala goodness.
For example, the web3j-scala
observable methods
provide simple and efficient application code.
Scala's value classes are used
to provide much stronger type safety than Web3J, without incurring a runtime penalty.
Add this to your SBT project's build.sbt
:
resolvers ++= Seq(
"micronautics/scala on bintray" at "https://dl.bintray.com/micronautics/scala",
"ethereum" at "https://dl.bintray.com/ethereum/maven/"
)
libraryDependencies += "com.micronautics" %% "web3j-scala" % "4.5.17" withSources()
This library is cross-built for Scala 2.12 and 2.13. Tested with Oracle JDK 8 and OpenJDK 8 & 11.
This library merely wraps Web3J, so if you have questions about how to use this library, please read their docs, and participate in their Gitter channel.
If you find a bug in this library you can post an issue here.
The demo program performs the following:
To run the demo:
geth
.bin/runGeth
script invokes geth
with the following options, which are convenient for development but not secure enough for production:
~/.ethereum
, or a subdirectory that depends on the network chosen;localhost:8545
is enabled, and all APIs are allowed.geth.ipc
,~/.ethereum
or a subdirectory.localhost:8546
is enabled, and all APIs are allowed.geth
output will be written, or overwritten, in logs/geth.log
;log/
directory will be created if it does not already exist.$ mkdir logs/
$ geth \
#--datadir .ethereum/devnet --dev \ # boots quickly but has no deployed contracts from others
--datadir .ethereum/rinkeby --rinkeby \ # takes about 15 minutes to boot, but has contracts
--ipcpath geth.ipc \
--metrics \
--rpc \
--rpcapi eth,net,web3,clique,debug,eth,miner,personal,rpc,ssh,txpool \
--shh \
--ws \
--wsapi eth,net,web3,clique,debug,eth,miner,personal,rpc,ssh,txpool \
--verbosity 2
You will see the message No etherbase set and no accounts found as default
.personal.listAccounts
which determines the account to send Ether too.--etherbase 0
.geth
continues to run,$ bin/demo
The demo has two major components:
web3j-scala
's synchrounous and asynchronous APIs
bin/web3j
script runs the Web3J command-line console.bin/
directory, including:
devnet
is used.geth
instance.geth
is listening on HTTP port 8545This library's Scaladoc is here and the gitter channel is here.
The Web3J JavaDoc is here, and here is the Web3J gitter channel.
build.sbt
and in this README.md
before attempting to publish to Bintray.$ git add -a && git commit -m "Comment here"
$ sbt publishAndTag
Use the Scaladoc project; first do a preflight check of the Scaladoc output:
sbt "; project web3j-scala; doc; project demo; doc"
Now edit the multi-scaladoc settings
export SCALADOC_SUB_PROJECT_NAMES="web3j-scala,demo"
Run multi-scaladoc:
../scaladoc/bin/run
This task rebuilds the docs, commits the git repository, and publishes the updated Scaladoc without publishing a new version:
$ sbt commitAndDoc
This project is sponsored by Micronautics Research Corporation, the company that delivers online Scala training via ScalaCourses.com. You can learn Scala by taking the Introduction to Scala, and Intermediate Scala courses.
Please contact us to discuss your organization’s training needs.
This software is published under the Apache 2.0 License.