Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


If you have any issues or ideas for improvements, please leave your feedback on the GitHub repository and on the NEO Discord.

Steps in the workshop

  1. Setup neo-python and a neo-privatenet Docker container optionally with neoscan
  2. First smart contract, just printing "Hello World":
    • Learn using neo-python's build command with the test argument
    • Test differences between Log and Notify
  3. First smart contract using print, Runtime.Log and Runtime.Notify:
    • Learn using neo-python's build command with the test argument
    • Test differences between Log and Notify
  4. Basic smart contract using storage:
    • Storage is one of the key components of most smart contracts
    • Everything is handled as bytes
    • Learn about debugstorage on/off/reset
  5. Check out Dictionary support and neo.Runtime.Serialize
  6. A domain registration smart contract:
    • users can query, register, transfer and delete domains
    • important concept: checking of ownership
  7. NEX ICO template:

Note: Inside neo-python's you need to run config sc-events on to see any kind of notifications of the examples!

Recommended System Setup

Linux or Mac is recommended, and you need Python 3.6+. If you are using Windows, either setup a VM or use the Linux Subsystem (see also here for more infos).

Clone neo-python and setup everything as described in the README. Then create a symlink of this workshop folder to neo-python/sc, which makes it easier to import, build and execute the smart contracts in this workshop.

Always work with a private network with this Docker image: You can also easily run the private network with neoscan - just use this Docker compose file:

$ wget -O docker-compose-neoscan.yml
$ docker-compose -f docker-compose-neoscan.yml up

See here for more information.


# Clone the workshop repository
git clone
cd python-smart-contract-workshop

# Pull the Docker image
docker pull cityofzion/neo-privatenet

# Start a private network
docker run --rm -d --name neo-privatenet -p 20333-20336:20333-20336/tcp -p 30333-30336:30333-30336/tcp cityofzion/neo-privatenet

# Download the private network wallet

# Create a Python 3.6 virtual environment and activate it
python3.6 -m venv venv
. venv/bin/activate

# Install neo-python
pip install neo-python

# Remove any old private chain database
rm -rf ~/.neopython/Chains/privnet*

# Start neo-python connected to the private net (-p), showing sc events (-v)
np-prompt -p -v

Typical method signatures

# These two are just examples for playing around and experimenting:
def Main():
def Main(operation):

# This is how most real smart contracts look like:
def Main(operation, args):

See also: parameter & return value types

Often used imports

from boa.interop.Neo.Runtime import Log, Notify
from boa.interop.Neo.Storage import Get, Put, GetContext
from boa.interop.Neo.Runtime import GetTrigger,CheckWitness
from boa.builtins import concat, list, range, take, substr

Often used build commands

neo> build sc/ test 07 05 True False
neo> build sc/ test 07 05 True False
neo> build sc/ test 07 05 True False
neo> build sc/ test 0710 05 True False query [""]

Useful code snippets


You can get the last block timestamp from the blockchain with this code.

def now():
    height = GetHeight()
    current_block = GetHeader(height)
    return current_block.Timestamp

Might not work with neo-boa 0.2.2, downgrade to 0.2.1 (see also CityOfZion/neo-boa#35).

Random numbers



Workshop for programming smart contracts with Python







No releases published


No packages published