Skip to content

Lightweight Java and Android library for integration with Ethereum clients

License

Notifications You must be signed in to change notification settings

qoire/web3j

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

web3j

Web3 Java Ðapp API

web3j is a lightweight Java library for integrating with clients (nodes) on the Ethereum network.

[ Your application ] + [ web3j ] <---> [ Ethereum node ]

It only has two runtime dependencies:

  • Apache HTTP Client
  • Jackson Core for fast JSON serialisation/deserialisation

Getting Started

Add the following dependency to your project:

Maven

tbc

Gradle

tbc

Start up an Ethereum client if you don't already have one running, such as Geth:

geth --rpc --testnet

To send synchronous requests:

Web3jService web3 = new Web3jService();  // defaults to http://localhost:8545/
Web3ClientVersion clientVersion = web3.web3ClientVersion().send();
clientVersion.getWeb3ClientVersion();

To send asynchronous requests using a Future:

Web3jService web3 = new Web3jService();
Web3ClientVersion clientVersion = web3.web3ClientVersion().sendAsync().get();
clientVersion.getWeb3ClientVersion();

Further Details

web3j is based on specifications from the JSON-RPC and web3.js projects.

It provides type safe access to all responses. Optional or null responses are wrapped in Java 8's Optional type.

Async requests are handled using Java 8's CompletableFutures.

Quantity data types are returned as BigInteger's. For simple results, you can obtain the quantity as a String via org.web3j.protocol.jsonrpc20.Response.getResult().

Tested clients

Geth

  • 1.4.10-stable-5f55d95a

More coming soon.

You can run the integration test class org.web3j.protocol.jsonrpc20.ProtocolIT verify other clients.

Coming Soon

  • Offline transaction signing
  • IPC interface support
  • WebSocket interface support

Related projects

For a .NET implementation, check out Nethereum.

For a pure Java implementations of Ethereum, check out the great work that EthereumJ are doing.

Thanks and Credits

  • The Nethereum project for the inspiration
  • Othera for the great things they are building on the platform
  • The Finhaus guys for putting me onto Nethereum
  • Everyone involved in the Ethererum project and surrounding ecosystem

About

Lightweight Java and Android library for integration with Ethereum clients

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 99.8%
  • Shell 0.2%