paint-brush
Deploying a NEP-5 smart contract (part 1)by@dominicfung_58781
682 reads
682 reads

Deploying a NEP-5 smart contract (part 1)

by Dominic FungAugust 18th, 2018
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

If you’ve haven’t set up a privet net already, please do so by taking a look at my previous articles, <a href="https://hackernoon.com/getting-started-on-a-neo-smartcontract-d36927e4bf1f" target="_blank">1</a> <a href="https://hackernoon.com/building-your-private-neo-network-on-aws-part-1-c01525dadc1c" target="_blank">2</a> &amp; <a href="https://hackernoon.com/building-your-private-neo-network-on-aws-part-2-4dc975744bf8" target="_blank">3</a>.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail

Coin Mentioned

Mention Thumbnail
featured image - Deploying a NEP-5 smart contract (part 1)
Dominic Fung HackerNoon profile picture

If you’ve haven’t set up a privet net already, please do so by taking a look at my previous articles, 1 2 & 3.

Before we begin, we need to cover the topic of smart contracts; what is it? A smart contract is a set of functional code (not object-oriented!), written to the blockchain via transaction and callable by wallets thereafter. A major advantage of NEO is that it supports many of today’s most well known languages such as C#, Python, Java … Our articles focus on the use of Python.

What is NEP-5? Similar to ERC20 for Ethereum, NEP-5 is a currency standard, recommending that you implement a couple of predefined functions (name, symbol, balanceOf, transfer … ). As with any standardization system, this allows digital wallets to focus on its demographic preferences without worrying about the token, while you [o lovely smart contract developer] does not need to worry about the user experience!

Lastly we cannot talk about deployment without talking about the compiler! We will need a compiler because NEO nodes do not understand Python or Java or C# or any other high level language. Instead, it understands byte code and it is the job of the compiler to translate it for us! Our compiler of choice will be Neo-boa: taking our NEP-5 compliant python smart contract, and turn it into byte-code or machine readable code.

Workflow summary: code → compile → deploy! let’s start!

Step 1: create your wallet

Open up the neo-prompt in Ubuntu, source venv/bin/activate , np-prompt -p <server ip> . Then:

create wallet testWallet1

enter a 10 character (minimum) password

Step 2: gathering funds

Your new wallet has no GAS in it (obviously) … but you need some to deploy contracts. Luckily, the network already has an importable WIF/private key with money inside.


import wif KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnrwallet rebuild

*the WIF may change at any time, refer to the documentation here

Step 3: pulling the an NEP-5 standard template from the internet

I will assume you already have git installed on your local. Open up a new command prompt:



:you may want to use the same base path as your neo-python installcd <storage location>git clone https://github.com/neonexchange/neo-ico-template

Step 4: installing Neo-boa (compiler)



:you may want to use the same base path as your neo-python installcd <storage location>git clone https://github.com/CityOfZion/neo-boa.git



cd neo-boa/python3.6 -m venv venvsource venv/bin/activate

pip install -r requirements.txt

Step 5: editing the smart contract code: getting the wallet hash

Go to your np-prompt console, and type wallet , you will see the following:

example testnet wallet

Copy the script hash at the top, mine is b’\xc6\x04\x1c\x97\x15\xc1\xe4\x87/\xe5\xbf\xd4\t\xf5\xe1\sbd_>\scd\xf8'

Using your favorite editor, open up <smartcontract>/nex/token.py . replace the TOKEN_OWNER with your own wallet hash.

Rename TOKEN_NAME and TOKEN_SYMBOL to anything you want!

Now you are ready to compile and deploy your personalized NEP5 smart contract!

Nodis.io is a marketing platform for local business, generating engagement through small activities and rewarding users with cryptocurrency they can later spend on stores. Check us out and give us your feedback on Instagram, Facebook and Telegram!

Follow me Instagram and Facebook as well!

Next week’s guide: Deploying a NEP-5 smart contract (part 2)

Quick thanks to thomas saunders and the NEX team for providing such an awesome smart contract template to explore!