Neb.js from Nebulas.io is the JavaScript solution for interacting with the Nebulas blockchain. It exports a suite of powerful tools:
Let's start by adding Neb.js to a new project.
To get up-and-running as quickly as possible, clone the following repository from GitHub: webpack-boilerplate.
git clone https://github.com/cvgellhorn/webpack-boilerplate.git
When cloning a repository, you can change the name of the projects root folder by adding an argument after the repositories URL:
git clone https://github.com/cvgellhorn/webpack-boilerplate.git neb-tutorial
After cloning the repo, navigate into the directory and install it's dependencies:
cd webpack-boilerplate && npm install
Now lets add Neb.js to our project:
npm install --save nebulas
If the previous command doesn't work, you can try installing directly from GitHub:
npm install --save https://github.com/nebulasio/neb.js.git
Once we've added Neb.js, we're good to go! Let's confirm it's working. Open up your favorite code editor and add the following to the bottom of app/index.js
import * as Neb from "nebulas"
let account = Neb.Account.NewAccount()
alert(account.getAddressString())
Now run the project:
npm run dev
Finally navigate to http://localhost:8080/ in your browser to see it in action.
Here's a live example of the previous directions applied to Nebulearn.com!
Generated Address: n1dZ7SfjpfyeSdoVceyFXW9CTxqc8PUE1u1
Congratulations, you've added Neb.js to your project and are ready to develop your epic DApp. Have fun exploring the exported modules mentioned at the start of this tutorial. Live long and Nebulas! 👾