Skip to content
Tutorial
Balance Reporting Bot

1. Project setup

Let's go step-by-step into initializing the project for this tutorial.

Initialize repository

Create working directory

Let's start from scratch from an empty directory:

bash
# create folder & jump into it
mkdir vault-bot && cd vault-bot

# init your git repository
git init

Mark un-needed files as ignored for Git

Create a .gitignore file with this content to ignore the node_modules folder & the env file (we will create it on next steps):

text
node_modules
.env

Initialize Typescript package

Create the Node.js package

This command will create the package.json with default content:

bash
# using `-y` option will make the init use all the defaults options
npm init -y

Install dependencies

Install the production dependencies:

bash
npm install --save axios dotenv

Then install the development dependencies:

bash
npm install --save-dev typescript tsx @types/node

Initialize Typescript configuration

Run this init command to create the tsconfig.json with default values:

bash
./node_modules/.bin/tsc --init

If everything worked correctly, you should have now a tsconfig.json file at the root of the repo.

Setup the main script

Create the script file

Let's create a main.ts file that will contain our code:

ts
console.log("Hello world!");

Add a npm script to run it

Edit the package.json file to add a new script entry. Let's remove the test script and add a dev script:

json
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
    "dev": "tsx main.ts"
  },
  "keywords": [],
  "author": "",

Verify that the setup works

Now, you can run this command to check that everything is OK:

bash
npm run dev

That should output:

text
> vault-bot@1.0.0 dev
> tsx main.tsx

Hello world!

Congratulations 🎉, we are ready to move to next step.