Skip to content
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 114 lines (77 sloc) 4.11 KB

NEO Smart Contract Workshop (Part 1)

by Steve for NEO

This workshop assumes intermediate knowledge of the command line.

This portion involves installing and setting up the environment. This is part 1 of the workshop. Part 2 is for command line operations. This portion involves interacting with neo-python command line.


Feel free to email your questions to me.


For errors, typos or suggestions, please do not hesitate to post an issue. Pull requests are very welcome! Thanks!

Task 0 - Install Pre-requisites

Before you start, make sure you have the following:

  1. Linux/Mac Operating System
  • Tested on Ubuntu (v16.04 and newer), Mint v18.3, CentOS v7.5, macOS Sierra
  1. Docker
  2. Python3.6 or later
  3. leveldb

For Docker, try running the following in terminal:

sudo apt-get install curl
sudo curl -sSL | sh
sudo apt-get update && apt-get upgrade
sudo service docker start

If you don't have Python 3.6, and have no idea how to install it, run the following commands:

sudo apt-get install software-properties-common python-software-properties
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python3.6 python3.6-dev python3.6-venv libleveldb-dev libssl-dev g++

For CentOS users, you can refer to this guide on how to install Python 3.6

Task 1 - Getting Started

In this session, we'll be setting up a local private blockchain which allows us to upload and execute smart contracts.

This will be hosted entirely on our own machines!

The process will go in the following order:

  1. Setting up the Docker Container
  2. Running NEO Python

1.1 Setting up the Docker Container

Pull the latest image from Docker hub
sudo docker pull cityofzion/neo-privatenet.

docker pull

Be patient! On the first time round it might take a while to start up.

The Docker image we're pulling is hosted on currently overseas servers. If you're downloading it from a country like China without any special internet tools, it may take hours to load the full image.

Start the container with the command
sudo docker run --rm -d --name neo-privatenet -p 20333-20336:20333-20336/tcp -p 30333-30336:30333-30336/tcp cityofzion/neo-privatenet.

You can open bash within the container with
sudo docker exec -it neo-privatenet /bin/bash.

Stop the container with
sudo docker rm -f neo-privatenet.

1.2 Running NEO Python

If you don't have git, run sudo apt-get install git

Navigate to a directory of your choice and download the neo-python repository with
git clone

Go into the neo-python folder with cd neo-python.

Create and start a virtual environment so our setup does not interfere with the rest of our machine.

sudo python3 -m venv venv
source venv/bin/activate

Install neo-python.

sudo pip3 install -r requirements.txt
sudo pip3 install -e .

Start neo-python with np-prompt -p. You should see something like this:

task 1 screenshot

You are now ready to move on to Part 2.


Special Thanks to Peter Lin, Jon and Chris Hager.

You can’t perform that action at this time.