From 7281d6e8c2da24488a64a9466f033dc2d1d4c7c7 Mon Sep 17 00:00:00 2001 From: deanc Date: Sat, 27 Apr 2024 14:21:14 +1000 Subject: [PATCH 1/2] Developer Setup Section --- DeveloperSetup/getting-started.md | 86 +++++++++++++++++++++++++++++++ DeveloperSetup/index.md | 16 ++++++ DeveloperSetup/index.yml | 3 ++ 3 files changed, 105 insertions(+) create mode 100644 DeveloperSetup/getting-started.md create mode 100644 DeveloperSetup/index.md create mode 100644 DeveloperSetup/index.yml diff --git a/DeveloperSetup/getting-started.md b/DeveloperSetup/getting-started.md new file mode 100644 index 0000000..d490bc1 --- /dev/null +++ b/DeveloperSetup/getting-started.md @@ -0,0 +1,86 @@ +--- +label: Setting up your Development Environment +order: 1100 +categories: + - Tutorials +tags: + - Developer Setup + - Web +--- +# Setting up your Dev Environment + +## What you will learn +After this, you will: +- [x] Know how to connect to a Verus node locally over rpc + +## Prerequisites: a locallly running Verus Node + +!!! danger +This is only for illustrative purposes. Do not use this in production scenarios. +!!! + +To interact with the Verus Protocol you will need to have access to a running Verus Node. A quick way to do that is to install the Verus Desktop app on your machine, which installs the verus daemon under the covers. Once installed, add the test chain to your Wallet and let it sync. Visit the [Verus Wiki](https://wiki.verus.io/#!index.md) for how to do this. + +### Authorisation using rpcuser and rpcpassword + +Locate the VRSC.conf file by opening **Show Verus data folder** under the Help menu in the Verus Desktop gui. Open the VRSC.conf file as you will need the rpcuser and rpcpassword values. + +!!!warning +Securing your Verus Node is critically important. Refer to the Verus Wiki on good practices. +!!! + +### Web App +For simplicity, we will create a simple node web app using Express that will send the `getinfo` command to the Verus Node, which will confirm we have a working Verus node able to interact with. We will use Visual Code manage this quick tutorial. + +Open Visual Studio Code and open a new folder to work in. Drop into your VS Code terminal: + +```bash +mkdir verusnode-express-app +cd verusnode-express-app +node install +touch app.js +``` + +Now oepn index.html and copy this into it, note to replace your rpcuser and rpcpassword values taken from your locally instaleld Verus node's VRSC.conf as described above. + +```javascript +const express = require('express'); +const axios = require('axios'); +const bodyParser = require('body-parser'); +const path = require('path'); +const app = express(); +const port = 3000; + +app.use(bodyParser.urlencoded({ extended: false })); +app.use(bodyParser.json()); + +const rpcUser = ''; +const rpcPassword = ''; +const rpcPort = 27486; // Replace with your RPC port + +const rpcURL = `http://${rpcUser}:${rpcPassword}@localhost:${rpcPort}`; + +app.get('/', (req, res) => { + res.sendFile(path.join(__dirname + '/index.html')); +}); + +app.post('/', (req, res) => { + const command = { + method: req.body.command, + params: [], + id: req.body.command + }; + + axios.post(rpcURL, command) + .then(response => { + res.send(response.data.result); + }) + .catch(error => { + res.status(500).send(`Error: ${error}`); + }); +}); + +app.listen(port, () => { + console.log(`App listening at http://localhost:${port}`); +}); +``` \ No newline at end of file diff --git a/DeveloperSetup/index.md b/DeveloperSetup/index.md new file mode 100644 index 0000000..eb722ad --- /dev/null +++ b/DeveloperSetup/index.md @@ -0,0 +1,16 @@ +--- +label: Developer Setup +order: 6000 +categories: + - Setup +tags: + - General +--- + +# Developer Setup Options + + +||| [Express Node Web App talks to Verus Node](/DeveloperSerup/getting-started.md) :technologist: + +Tutorial: node express web app that talks to a local Verus node. +||| \ No newline at end of file diff --git a/DeveloperSetup/index.yml b/DeveloperSetup/index.yml new file mode 100644 index 0000000..ad61c4e --- /dev/null +++ b/DeveloperSetup/index.yml @@ -0,0 +1,3 @@ +icon: id-badge +label: Developer Setup +order: 5000 \ No newline at end of file From 68856fa6e2689356c3fd41a726cd8297b46a6e46 Mon Sep 17 00:00:00 2001 From: deanc Date: Sat, 27 Apr 2024 14:22:47 +1000 Subject: [PATCH 2/2] fix typo in developersetup link --- DeveloperSetup/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DeveloperSetup/index.md b/DeveloperSetup/index.md index eb722ad..8fae08c 100644 --- a/DeveloperSetup/index.md +++ b/DeveloperSetup/index.md @@ -10,7 +10,7 @@ tags: # Developer Setup Options -||| [Express Node Web App talks to Verus Node](/DeveloperSerup/getting-started.md) :technologist: +||| [Express Node Web App talks to Verus Node](/DeveloperSetup/getting-started.md) :technologist: Tutorial: node express web app that talks to a local Verus node. ||| \ No newline at end of file