This is perhaps a stupid question but i'm not getting it. How do you use Embark in NodeJS or is it client side JavaScript only. Because in the demo there is no server side code. It looks like it's using it's own webserver. That is fine for the demo environment but I want to incorporate it into my own webserver. Maybe I'm just missing something but I'm just not seeing it

2 Answers 2


There are plenty of good reasons to run a server-side ethereum connection. If you want to do so:

install web3 directly. Embark has it's own version of web3, but I found it easiest just to install it local to my site

npm install web3

Instantiate Web3 in your node.js script

var Web3 = require('web3');
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

Copy/link your dist/contracts folder somewhere accessible to your site. Then import the json for the contract you wish to interact with:

sc_abi = require('./contracts/<YourContract>.json');

Finally, instantiate a web3 object and away you go...

MyContract = new web3.eth.Contract(sc_abi.abi, sc_abi.address);

DApps are meant to be client side only, the dev webserver of embark is there as a convenience to easy access the dapp for development purposes. You can put the dapp anywhere: in your own webserver, ipfs and even distribute it as a zip file since the dapp can be even open directly in the browser as a file.

  • Is having a server side DApp with a REST api considered not done? or not conventional. In the context of a private chain having some business logic is more convenient on the server side than the client side Commented Mar 27, 2017 at 13:28

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.