4

I am familiar creating Dapps by using Web3.js , I could able to do so , even in a normal browser ( without Mist). But wondering if that is possible by using EthereumJ ?

So instead of browser ( web3.js) connecting directing to the network and getting it done, the request should go through our hosted server which serves the data by using EhtereumJ ?

My Intention to use spring mvc web application.

3
  • What the aim of adding this server step? It removes the decentralized advantage of blockchain. May 24, 2016 at 14:42
  • 1
    Agreed @NicolasMassart, But I am planning for a centralized system ( private blockchain) . And moreover our application is going to be a hybrid solution ( part blockchain part enterprise application ).Due to the fact that blockchain would be slow for the model I thought of. May 24, 2016 at 14:52
  • so yes it's possible. Without knowing your entire project however I can't tell you if it's the best architecture. May 24, 2016 at 15:43

3 Answers 3

3

You could probably do this, but it's unlikely to be the best approach.

All three main clients expose a set of APIs via JSON-RPC; this is what web3 apps call. Instead of integrating directly with a client, you should run a stock node, and call these APIs from your webapp.

1

I know this is a tad late but my 2 cents since I just got back around to EthereumJ.. Just some ideas for people who may stumble on this..

Java has a webview client built in, https://docs.oracle.com/javase/8/javafx/api/javafx/scene/web/WebView.html.

I was working on a project similar to what you're asking about, using ethJ and webview, before the json-rpc interface was implemented. I'd explore using the webview function to display HTML interfaces with some js interacting with the core through RPC. You can expose java classes and methods to javascript but I do not know how flexible or convenient that is for you.

You could then run an ethereum node on each client and host the HTML on the server.

This would be the best use of the blockchain. You could tell the nodes to look for the blockchain data at the server IP as well if you wanted to edit the core, but then you lose consensus.

You could run a full node on the server and your lite nodes could interact through one of the many libraries that use http.

Here's a project I found using webview to browse the ethereumJ blockchain https://github.com/Bitcoinzie/EthChainExplorer I doubt it still works as it's a pretty old repo, but it shows how to accomplish what your asking.

0

I created the web3j for solving exactly this problem. It is a lightweight Java library for talking to Ethereum clients (EthereumJ, Geth, Parity, ...) over JSON-RPC.

My focus is on keeping it lightweight (i.e. keeping dependencies to an absolute minimum), so you can integrate it easily with frameworks such as Spring on your project.

It supports all of the core JSON-RPC Ethereum specification, provides synchronous and asynchronous requests, and wraps all requests/responses in suitable types to take advantage of Java's static typing.

Web3j web3 = Web3j.build(new HttpService());  // defaults to http://localhost:8545/
Web3ClientVersion web3ClientVersion = web3.web3ClientVersion().sendAsync().get();
String clientVersion = web3ClientVersion.getWeb3ClientVersion();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.