A step by step guide to setting up an Obyte Bot Development Environment on your PC.
Before we can start coding, we’ll need to get Node and npm installed on your machine.
To check that Node and npm are installed correctly, open your terminal and type:
node -v
followed by:
npm -v
That will output the version number of each program. At the time of writing, my Node js version is v10.10.0 my npm version is 6.4.1. Make sure that your version of Node js is a stable version.
You will need to have a good editor installed on your machine. I use Atom
In the command prompt window, go to the parent folder of where you want to create your new project directory, e.g. .../Projects
folder and a get sample bot code from Github by running the following command:
git clone https://github.com/byteball/bot-example.git
Rename the bot-example
directory, e.g. .../Projects/obyte-Stack-Game
Remove the .git
sub-directory and .gitignore
file.
We are going to run this tutorial on the latest test branch. So will need to change dependencies as well as update other config parameters.
Remove "repository": "https://github.com/byteball/bot-example.git",
line from the package.js
file and update config as following:
{ "name": "obyte-stack-game", "version": "1.0.0", "description": "Obyte Stack Game Bot", "main": "start.js", "author": "Whistling Frogs", "license": "MIT", "dependencies": { "ocore": "git+https://github.com/byteball/ocore.git#rocks-and-formulas", "headless-obyte": "git+https://github.com/byteball/headless-obyte.git#aa" } }
We are running this tutorial on testnet, so copy .env.testnet
into .env
file.
In the command prompt window, go to your new project directory and run:
npm install
I got a lot of gyp
errors from secp256k1@3.7.1 rebuild
, but it did not seems to affect things.
Modify the config.js
file with your config parameters.
We are going to run a light node
, so leave following line as is:
exports.bLight = true;
Update exports.deviceName = 'Bot example';
with the name of your bot, for example:
exports.deviceName = 'My Bot';
Set exports.permanent_pairing_secret
, for example
exports.permanent_pairing_secret = 'mySecret';
Set exports.control_addresses
to the Device Address of your testnet GUI Wallet, that can be found in the SETTINGS Global preferences of your wallet, e.g.
exports.control_addresses = ['03IZO575EMSLKLXYADRSCWQGMBJGRIVXC'];
Set exports.payout_address
to the Obyte Address of your testnet GUI Wallet, that can be found by clicking on the RECEIVE icon, e.g.
exports.payout_address = 'B7KF2F5AP6BZLXOE2EGHH6BKZWVNIKWF';
If you are intending to follow up this tutorial with my tutorials for the Obyte Stack Game Bot and AA, you will need to change the config to use a Single Address headless Wallet. In which case, set exports.bSingleAddress
to true;
exports.bSingleAddress = true;
And finally configure exports.admin_email
by setting it to your email address.
Decide on your secret Passphrase
. Make it short and easy to remember. You would need to enter it every time you start your bot. As you are running in test mode, make a note of your Passphrase
.
Complete the install by running node start.js
at the command prompt.
node --max-old-space-size=4096 start.js
You will be prompted for a Passphrase:
enter it.
The process will continue running and will initialise your bot and create a new directory under your user AppData/Local
directory, which will have the same name as your project directory. This directory will contain a log file and a sqlight database, which will be used to store your light node data.
The bot will generate a new Single Address Wallet and Parring code, which will be displayed on the console. For example:
====== my device address: 0FGXQ6AOUOLKYHP5WVBUR6MPGNZVV3XDN ====== my device pubkey: A/R1S1zX9R9KzN34IA5PCUbEFRB5WEDLEdVaNo/0s/Xu ====== my pairing code: A/R1S1zX9R9KzN34IA5PCUbYbRB5WEDLEdVaNo/0s/Xu@obyte.org/bb-test#StackGame ... ====== my single address: 4H2FOFBP7ST6BLYWHZ3GUV5PHY626AM4
Note the pairing code. Users will need it to pair with your bot.
If you get the following error:
Error("Looks like you are loading multiple copies of ocore, which is not supported.
Check your dependencies in the package.js
file to be as described earlier.
If you are having to make changes to the package.js
file. You will need to delete node_modules
folder and package-lock.json
file and run npm install
again.
To pair with your bot, open your testnet Obyte Wallet, click on the CHAT
icon, then click on the + Add a new device
link. Then click on the ACCEPT INVITATION FROM THE OTHER DEVICE
, enter your Parring code
and click on the Pair
button.
You should get a welcome message from your new bot:
Welcome to my new shiny bot!
Please note, that if you have changed the config of the bot to the single address, the bot will not work properly at this stage as this is not what the original sample bot was designed for.
For testing purposes, you may want to pair your bot with a number of different devices, e.g. laptop, phone.
Follow the Obyte Stack Game Bot Tutorial to learn how to modify sample bot into a stack game bot.