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": "3.1.401"
  }
}

This tells your local C# .NET runtime to use version 3.1.401 in this repo, even if you have newer versions installed on your machine.

You may need to also add environment variables to get the NEO•ONE node working. The NEO•ONE node now uses the C# NeoVM instead of our own implementation of the NeoVM in TypeScript, which means that NEO•ONE controls C# code through some complicated mechanisms. If you run into problems with running a node (such as when running neo-one init or neo-one build) then try these steps:

  • 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/netcoreapp3.0
  • 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
  • Try running the NEO•ONE CLI command using sudo, such as: sudo npx neo-one init
  • If problems persist 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