Quick Setup: NEO Private Net w/gas

in #neo7 years ago (edited)

This is a quick tutorial on starting up a NEO private net w/GAS on either PC or Mac with Docker and neo-python, without locally installing python.

Install Docker

Create folder for smart contract code

Open a terminal

Very important: Navigate to, or create a folder to hold your smart contract code. We will be linking this folder to be shared with the docker container, so that you can access your smart contract files from within the container.

For example:

Start the docker container

We will be using neo-privnet-with-gas. It contains the neo private net instance with the NEO/GAS already in a wallet.

Run the command

docker run -d --name neo-privnet-with-gas -p 20333-20336:20333-20336/tcp -p 30333-30336:30333-30336/tcp -v "$(pwd)":/opt/neo-python/smartContracts metachris/neo-privnet-with-gas


Check to make sure the container is running

docker ps

SSH into the docker container by running

docker exec -it neo-privnet-with-gas /bin/bash


Navigate to the neo-python folder

cd opt/neo-python


In this folder you should see the smartContracts folder. It is linked to the local directory on your host machine.

Download the pre-made wallet

curl https://s3.amazonaws.com/neo-experiments/neo-privnet.wallet -o main.wallet


Jack into the matrix neo privnet container

python3 prompt.py -c protocol.privnet.json

You should now be in the neo command line. This will be where you interact with your private neo net.

Open the pre-made wallet

open wallet main.wallet


Enter the wallet password

coz


Rebuild the wallet

wallet rebuild

Check the wallet balance

wallet

The wallet should have the 100m NEO and ~6k GAS

Congrats! You are now officially set up, and have taken the first step on your way to start writing your own dapps and smart contracts!


If you found this tutorial helpful, please donate at:

NEO/GAS/NEP5 tokens: AR8rRBxgWw5siKsp1dUmfTLy6QQTjcqoqB
ETH/ERC20 tokens: 0x575970777095575fDd12d9cD3B105b41D8DD1344
NANO/XRB: xrb_3rpmim57tqbrb8hhjfzm1x5uk135yhmgqoj7j7wsufpo53e3ad5k93ggy1cd
LTC: M8nZ7FwJXSMAkAfiGmTKjbB7MWpdwsp52d
BTC: 3LcA1ztxFjghexRNWPyGXA59VFU3gF4PTz
BCH: 1LXLiF7SjWGday6gm61hzbYHKbSAMevwXo
Sort:  

Thanks, worked great. I'm going to try and learn all I can about this.
What is the best way to stop the private net and the container?
and how do I restart them another day?

Please let me know if this is correct to shut it down;
My guess is to use 'quit' to stop Neo in terminal, then 'exit' from neo-python, then click 'quit Docker' from the Docker app.
Anything else?

Glad you were able to get all set up! If you want to restart the container you can do the following:

docker ps

This will list all the active containers. Get the container id of the neo privnet, and remove it with:

docker rm {CONTAINER_ID}

If you are feeling extra fancy, you can checkout my other post on create bash scripts for these things ^^
https://steemit.com/neo/@z0yo/neo-smart-contracts-workflow-improvements