Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Development Environment Setup

This is Gabriel Cardona's AVA Labs-centric development environment setup. Use at your own risk. Your mileage may vary.

Terminal

iTerm2 is a replacement for Terminal

Shell

I prefer zsh to bash. Here is a small list of the many features which make zsh my preference.

  • Automatic cd: Just type the name of the directory
  • Recursive path expansion: For example /u/lo/b expands to /usr/local/bin
  • Spelling correction and approximate completion: If you make a minor mistake typing a directory name, ZSH will fix it for you
  • Plugin and theme support: ZSH includes many different plugin frameworks

As of MacOS 10.15.x Catalina the default shell on a Macbook is zsh.

oh-my-zsh is a delightful, open source, community-driven framework for managing your Zsh configuration. It comes bundled with thousands of helpful functions, helpers, plugins, and themes.

Install via curl

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Install via wget

sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

GoLang

Install GoLang version >= 1.15.5 and set up it's $GOPATH.

AvalancheGO

AvalancheGo is the official node implementation of the Avalanche network

Clone the repo

go get -v -d github.com/ava-labs/avalanchego/...
cd $GOPATH/src/github.com/ava-labs/avalanchego

Build the executable

./scripts/build.sh

The Avalanche binary, named avalanchego, is in the build/ directory.

Avash

Avash is the avalanche shell client. It is the Avalanche network's local/private testnet.

First build AvalancheGo. Then:

go get github.com/ava-labs/avash
cd $GOPATH/src/github.com/ava-labs/avash
go build

Now you can fire up a 5 node staking network:

./avash
Config file set: /Users/username/.avash.yaml
Avash successfully configured.
avash> runscript scripts/five_node_staking.lua
RunScript: Running scripts/five_node_staking.lua
RunScript: Successfully ran scripts/five_node_staking.lua

POSTMan Collection

The POSTMAN Collection has full support for the entire RPC of the X-Chain, C-Chain and P-Chain.

Node Version Manager

nvm is a version manager for node.js, designed to be installed per-user, and invoked per-shell. Currently we're using nodeJS v12.14.1. There's a new LTS but our wallet team has asked that we stay on this version due to issues upgrading the web wallet.

Install

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

List remote versions

nvm ls-remote

List installed versions

nvm ls

Install a version

nvm install v14.16.0

Use an installed version

nvm use 14.16.0

Default to an installed version

nvm default 14.16.0

TS Node

ts-node is a TypeScript execution and REPL for node.js, with source map support.

Installation

# With TypeScript.
npm install -g typescript
npm install -g ts-node

Usage

# Execute a script as `node` + `tsc`.
ts-node script.ts

# Starts a TypeScript REPL.
ts-node

VSCode Debugging

VSCode is a great text editor and Typescript development environment. Debugging

TSConfig

{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "lib": ["es2015", "dom"],
    "allowJs": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "outDir": "dist",
    "strict": true,
    "noImplicitAny": true,
    "moduleResolution": "node",
    "baseUrl": "./",
    "esModuleInterop": true
  },
  "include": ["*"],
  "exclude": ["node_modules"]
}

.vscode/launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      "skipFiles": [
        "<node_internals>/**"
      ],
      "program": "${workspaceFolder}/FILENAME-TO-CHANGE.ts",
      "preLaunchTask": "tsc: build - tsconfig.json",
      "outFiles": [
        "${workspaceFolder}/dist/**/*.js"
      ]
    }
  ]
}

Usage

  1. Add breakpoinst to FILENAME-TO-CHANGE from the previous step.
  2. Open the "Run" tab with cmd+shift+D.
  3. Have the top dropdown menu read "Launch Program" and click the green "Start Debugging" play button.
  4. If you see a popup error click "Debug Anyway"
  5. You'll now be debugging. You can step over/in/out of functions. You can observe the stack. You can inspect variable values and call methods from the debug terminal tab.

AvalancheJS

AvalancheJS is the javascript/typescript client for the Avalanche Network. To build the library locally

git clone https://github.com/ava-labs/avalanchejs.git
cd avalanchejs
npm install
npm run build
npm test

There are dozens of example scripts(https://github.com/ava-labs/avalanchejs/tree/master/examples) to test which you can run with ts-node. First make sure that a local network is running via avash.

ts-node examples/info/peers.ts
[
  {
    ip: '127.0.0.1:57292',
    publicIP: '127.0.0.1:9655',
    nodeID: 'NodeID-NFBbbJ4qCmNaCzeW7sxErhvWqvEQMnYcN',
    version: 'avalanche/1.2.0',
    lastSent: '2021-02-16T16:24:42-08:00',
    lastReceived: '2021-02-16T16:24:42-08:00'
  },
  {
    ip: '127.0.0.1:57291',
    publicIP: '127.0.0.1:9653',
    nodeID: 'NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ',
    version: 'avalanche/1.2.0',
    lastSent: '2021-02-16T16:24:42-08:00',
    lastReceived: '2021-02-16T16:24:42-08:00'
  },
  {
    ip: '127.0.0.1:57294',
    publicIP: '127.0.0.1:9657',
    nodeID: 'NodeID-GWPcbFJZFfZreETSoWjPimr846mXEKCtu',
    version: 'avalanche/1.2.0',
    lastSent: '2021-02-16T16:24:42-08:00',
    lastReceived: '2021-02-16T16:24:42-08:00'
  },
  {
    ip: '127.0.0.1:57293',
    publicIP: '127.0.0.1:9659',
    nodeID: 'NodeID-P7oB2McjBGgW2NXXWVYjV8JEDFoW9xDE5',
    version: 'avalanche/1.2.0',
    lastSent: '2021-02-16T16:24:42-08:00',
    lastReceived: '2021-02-16T16:24:42-08:00'
  }
]

Web Wallet

Web Wallet

Faucet

Faucet

Documentation

Social

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment