Setting up your development environment (Part 2)

in neo •  6 years ago  (edited)

 A working development environment is essential before starting any development. The setup of a development environment varies  in complexity, depending what  is developed.For a simple Website a Text Editor, HTML file and a Browser might be enough to start. For a C# application you can use an Integrated Development Environment (IDE) and it sets up your compiler, useful tools like code Highlighting, a Debugger and much more for you.

Now what do you need for a NEO Development environment?

NEO is an advanced blockchain, which needs at least four consensus nodes to run  a test network, which is needed for your NEO development environment. Then you need ways to interact with the test network such as:

  1. Send and receive assets  
  2. Deploy your Smart Contracts (SC)
  3. Seed the status of the blockchain
  4. Call actions of Smart contracts
  5. Debug your smart contract

Public NEO TestnetNEO provides a sample testnet: http://docs.neo.org/en-us/network/testnet.html However during development you will see, that you have to redeploy your smart contract a lot of times. This goes way faster if you setup your own testnet blockchain. And is not that hard, there is a prepared docker image. Therefor I will tell you now, how you can setup your own testnet via docker.

Setup your own NEO Testnet with docker

Setting up the NEO testnet with docker is ‘pretty’ easy. After registering to docker and downloading and installing the latest version, download https://github.com/slipo/neo-scan-docker and unzip it or better: run git clone https://github.com/slipo/neo-scan-docker.git. Now you have the docker compose files, which you can start with docker-compose up. This will take a while to download the three docker containers:

  1. Neo-scan
  2. Postgresql
  3. neo-privnet

For me this did hang the first time but after a retry I got the following console outputs.(Note: I was using powershell as command line interface).Image: https://imgur.com/a/URdHw1L As you can see by the log messages, blocks are generated so our environment is running fine :) Addition: In some cases, I had to kill the docker instances before restarting it again. I used the following command: Kill all containers  >docker ps -a -q | ForEach { docker stop $_ }  

NEOSCAN - What happens on your blockchain

Now you are running your own NEO testnet, but what is happening on it? Luckily the docker image comes with NEOSCAN too. This is the same Neoscan you can access under https://neoscan.io/, just for your private network. Access it under http://localhost:4000 . The following screenshot shows my private blockchain and a few transactions I made with it. Image: https://imgur.com/a/URdHw1L

NEO Wallet - Where is my Money

So you set up the docker container, so now you must be rich. It is your blockchain, so you have at least 100.000.000 NEO, which constantly generate GAS. So beside it being a testnet, how do you access it (and congrats, if you can sell somebody your Testnet NEO)? Well first, we need the NEO-GUI Client, which you can download here: https://github.com/neo-project/neo-gui/releases The NEO-GUI is configured to connect to the mainnet of NEO. However if you look into all the files, you can also

  • config.json
  • config.mainnet.json
  • config.testnet.json

"config.json" is the configuration used by neo-gui, by default this is the mainnet. "config.mainnet.json" is a backup of this file, and "config.testnet.json" is for the official NEO Testnet. In order to connect to your testnet you have to create your own configuration with your testnet ports. For you this shouldn’t look different them my configuration. Config.json 

{  "ApplicationConfiguration": {    "Paths": {      "Chain": "Chain_{0}",      "CertCache": "Certs"    },    "P2P": {      "Port": 10333,      "WsPort": 10334    },    "Urls": {      "AddressUrl": "http://localhost:4000/address/{0}",      "AssetUrl": "http://localhost:4000/api/main_net/v1/get_asset/{0}",      "TransactionUrl": "http://localhost:4000/transaction/{0}"    }  }} 

"Localhost” is used, because it is running on your local machine. The ports match the ones defined in the docker image, but changing them exceeds a basic tutorial.  Secondly we need to modify the “protocol.json”. As with “config.json”, “protocol.json” comes with examples for mainnet & testnet. 

Our “protocol.json” looks the following:

{    "ProtocolConfiguration": {        "Magic": 56753,        "AddressVersion": 23,        "SecondsPerBlock": 15,         "StandbyValidators": [            "02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2",            "02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e",            "03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699",            "02a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd62"        ],        "SeedList": [            "127.0.0.1:20333",            "127.0.0.1:20334",            "127.0.0.1:20335",            "127.0.0.1:20336"        ],        "SystemFee": {            "EnrollmentTransaction": 1000,            "IssueTransaction": 500,            "PublishTransaction": 500,            "RegisterTransaction": 10000        }    }} 

We only have four StandbyValidators because our NEO setup runs only with four notes, while the mainnet is running with seven, and more are comming. SeedList points to our local machine, the rest is the same. Now when you start NEO-GUI, you should see it syncing with the blockchain until it reaches the same number of blocks as your testnet. Now you just have to access your NEO. You can do this with “Wallet” -> “New Wallet Database”.Fill  out the modal by creating a new wallet file in a folder (select a folder, enter a new name) and give a password you remember. This creates your wallet, and you see a single address with 0 NEO and 0 GAS, but where is your money?!Your Money is in a different account. Add it by right clicking the window → Import → Import from WIF.In the Model enter the following “WIF Private Key”: KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnrThis adds a second account with the adress AK2nJJpJr6o664CWJKi1QRXjqeic2zRp8y the 100.000.000 NEO Balance. Yeahhhh  Image: https://imgur.com/a/URdHw1L

Conclusion

To say this is too easy would be an understatement. I’m currently on 9th page of my Tutorial demo. But it is crypoto, hard complex mathematical operations, which secure a network to build complex dAPPs. In the next chapter we will build our first dAPP. See you then!  
 

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Congratulations @kern.pro! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

Click here to view your Board

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @kern.pro! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!