n-riesco / ijavascript

IJavascript is a javascript kernel for the Jupyter notebook
Other
2.19k stars 185 forks source link

Question: can geth and web3.js APIs be accessed with ijavascript? #176

Closed cheburakshu closed 5 years ago

cheburakshu commented 6 years ago

I have a question.

Can ijavascript be used for bringing up and working with a geth ethereum console which is based on npm?

n-riesco commented 6 years ago

IJavascript runs Javascript inside a Node.js session. So the answer to your question is yes, it is.

IJavascript is able to require npm packages. You need to make sure that they've been installed and that require can find their location. This depends on your setup.

Here's a quick&dirty way to do it:

$ mkdir myproject
$ cd myproject
$ mkdir node_modules
$ npm i web3 geth
$ ijsnotebook

image

The key idea is that you need to ensure require can find the location where web3 and geth have been installed.

Most frontends set the working directory to the same folder where your notebook file is.

IJavascript also provides the flag --working-dir=path to set the working directory (see here).

cheburakshu commented 6 years ago

Woohooo. Thanks!!

On Tue, Nov 13, 2018 at 10:00 AM Nicolas Riesco notifications@github.com wrote:

IJavascript runs Javascript inside a Node.js session. So the answer to your question is yes, it is.

IJavascript is able to require npm packages. You need to make sure that they've been installed and that require can find their location. This depends on your setup.

Here's a quick&dirty way to do it:

$ mkdir myproject $ cd myproject $ mkdir node_modules $ npm i web3 geth $ ijsnotebook

[image: image] https://user-images.githubusercontent.com/6199391/48428939-f8fe6400-e763-11e8-87e7-1f8cf9cd4f54.png

The key idea is that you need to ensure require can find the location where web3 and geth have been installed.

Most frontends set the working directory to the same folder where your notebook file is.

IJavascript also provides the flag --working-dir=path to set the working directory (see here https://github.com/n-riesco/ijavascript#ijsinstall-ijavascript-kernel-spec-installer ).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/n-riesco/ijavascript/issues/176#issuecomment-438349107, or mute the thread https://github.com/notifications/unsubscribe-auth/AaEF0v53zrN8vVaGnZ6w49RX9TLxMM9kks5uuvqXgaJpZM4YaUqy .

-- Thanks and Regards, Sudharsan Rajagopalan

EdsonAlcala commented 5 years ago

Very nice ! I actually had the same question, very nice feature !!