Environment Setup

NEO•ONE was designed to get your dapp up and running quickly.

This page describes how to setup NEO•ONE using yarn or npm.



Requirements


Installation

If you’re just getting started, try out one of the following toolchains for setting up your project:

Make sure you add this global.json file to the root of your project repo:

{
  "sdk": {
    "version": "5.0.302"
  }
}

This tells your local C# .NET runtime to use version 5.0.302 in this repo. Make sure you are using versions 5.0.3xx. You can view the installed SDKs by typing dotnet --list-sdks on the console. To confirm you are using a compatible version, type dotnet --version inside the project folder. NEO•ONE will use the latest version unless it sees the global.json. This is required because NEO•ONE node uses the official C# NeoVM under the hood.

You need to add environment variables to get the NEO•ONE node working.

On Windows:

  • Add these environment variables to your shell environment:
    • EDGE_USE_CORECLR=1
    • EDGE_APP_ROOT=<path/to/project>/node_modules/@neo-one/node-vm/lib/bin/Debug/net5.0
      • If after adding EDGE_APP_ROOT and EDGE_USE_CORECLR to the shell environment you still get errors then add the same EDGE_APP_ROOT variable before the shell command that you are trying to run with NEO•ONE. For example: EDGE_APP_ROOT=<path/to/project>/node_modules/@neo-one/node-vm/lib/bin/Debug/net5.0 npx neo-one start network.

On macOS:

  • Add these environment variables to your shell environment:
    • EDGE_USE_CORECLR=1
    • EDGE_APP_ROOT=<path/to/project>/node_modules/@neo-one/node-vm/lib/bin/Debug/net5.0
      • If after adding EDGE_APP_ROOT and EDGE_USE_CORECLR to the shell environment you still get errors then add the same EDGE_APP_ROOT variable before the shell command that you are trying to run with NEO•ONE. For example: EDGE_APP_ROOT=<path/to/project>/node_modules/@neo-one/node-vm/lib/bin/Debug/net5.0 npx neo-one start network.
  • Install pkgconfig on macOS with Homebrew: brew install pkgconfig
    • Then add this environment variable: PKG_CONFIG_PATH=/Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig
    • You then need to re-install your node modules by deleting the node_modules folder and then running npm install again

Testing your setup:

  • Use npx neo-one start network. The output should be something like {"level":30,"time":1625855073745,"service":"node","service":"blockchain","name":"neo_blockchain_start","msg":"Neo blockchain started.","v":1}. You may need to use sudo depending on your project configuration.
  • If you run into problems, then please reach out to us on Discord

To see a demonstration of environment setup go to our YouTube channel for helpful videos.

Once you have a project setup, the next step is to add NEO•ONE to it. NEO•ONE is organized into multiple individual packages. Use as much or as little as you like. Each package may be installed using either yarn (yarn add <package name>) or npm (npm install <package name>). Each package has the form @neo-one/<name>, for example, @neo-one/client.

Make sure to install the correct versions of these packages. If you are working on Neo3 then make sure you are installing NEO•ONE packages at version 3.0.0 or higher.

Install all the neo-one packages with yarn by running:

yarn add @neo-one/cli@prerelease @neo-one/client@prerelease @neo-one/smart-contract@prerelease @neo-one/smart-contract-test@prerelease @neo-one/smart-contract-lib@prerelease @neo-one/smart-contract-typescript-plugin@prerelease

Install all the neo-one packages with npm by running:

npm install @neo-one/cli@prerelease @neo-one/client@prerelease @neo-one/smart-contract@prerelease @neo-one/smart-contract-test@prerelease @neo-one/smart-contract-lib@prerelease @neo-one/smart-contract-typescript-plugin@prerelease

and then follow the main guide or the tutorial. By the end of it you’ll know which features of NEO•ONE you’re using and which packages to keep.

Know what you want to use from NEO•ONE? Read on to see which packages to install for specific functionality.

For interacting with smart contracts, you should install

  • @neo-one/client - Main entrypoint to the most common NEO•ONE client APIs.

For local network and smart contract management, you should install

  • @neo-one/cli - Provides the neo-one cli command which manages common tasks like building and deploying smart contracts and spinning up local networks.

In addition to the above, if you’re developing TypeScript smart contracts using NEO•ONE, you should install

  • @neo-one/smart-contract - TypeScript smart contract standard library.
  • @neo-one/smart-contract-test - TypeScript smart contract testing utilitiees.
  • @neo-one/smart-contract-lib - Template library for common smart contract patterns.
  • @neo-one/smart-contract-typescript-plugin - TypeScript language server plugin for inline compiler diagnostics in your favorite IDE.

Update

# npm update @neo-one/cli
yarn upgrade @neo-one/cli

Editor Setup

Configure your IDE to use your local TypeScript installation and the @neo-one/smart-contract-typescript-plugin in order to take advantage of inline compiler diagnostics. These instructions are for VSCode, but they should be similar for any editor that supports TypeScript IntelliSense.

  1. Ensure @neo-one/cli and @neo-one/smart-contract-typescript-plugin are installed.
  2. Run yarn neo-one init or npx neo-one init. This will create a tsconfig.json file in the configured smart contract directory (by default, neo-one/contracts/tsconfig.json).
  3. Open a TypeScript file, then click the TypeScript version number in the lower right hand side of your editor and choose "Use Workspace Version"

That’s it! Enjoy inline smart contract compiler diagnostics.

Javascript Environment Requirements

NEO•ONE depends on several types which older browser may not support. NEO•ONE requires the collection types Map and Set as well as Symbol.asyncIterator. If you support older browsers and devices which may not yet provide these natively, consider including a global polyfill in your bundled application, such as core-js or babel-polyfill.

To polyfill an environment for NEO•ONE using core-js, include the following lines at the top of your entry point.

import 'core-js/es/map';
import 'core-js/es/set';
import 'core-js/es/symbol/async-iterator';
Edit this page
  • Quick Start
  • Getting Started
  • Environment Setup
  • CLI
  • Contract Mixins
Previous Article
Getting Started
Next Article
CLI
DOCS
InstallationMain ConceptsAdvanced GuidesAPI ReferenceContributing
CHANNELS
GitHubStack OverflowDiscord ChatTwitterYouTube
COPYRIGHT © 2021 NEO•ONE