Tutorial on EOS Contracts and some Windows tooling
Hello and welcome to a fun little tutorial around some great tooling created by us, EOS New York, that hopefully will make the life of the elusive Windows EOS Developer a bit easier.
So what is a pongpingpong you may be asking. pongpingpong is an EOS smart contract tutorial that revolves around EOS Easy Contract, Windows Developers, and eventually some more advanced smart contract contracts. Part I will focus on getting everyone up to speed on creating, compiling, and deploying their smart contract. Follow up sections will revolve around more advanced smart contracts such as inline actions, multi-index databases, and "the Trust and Confirm model". At the end of this tutorial you should be able to setup a Windows environment for smart contract development.
Prerequistes This project requires Docker for Windows (of course) and my new favorite text editor, IDE, and all around good guy VS Code. Both of these tools have great communites with tons of information available regarding setup and customization. The final requirement is the brainchild of our very own Warrick. He spent a rainy weekend holed up creating EOS Easy Contract. We will be using this project to create, compile, and deploy a smart contract.
Our goal here is to get any developers from the Windows world who may be unsure of how get into the EOS development game. There is a ton of tooling for Mac and Linux but no love for the Windows Dev. Hopefully this opens some doors for those characters.
I am going to assume that you have installed Docker and VS Code using the links above. Now it is time to get EOS Easy Contract heading to the github link and following the setup instructions there.
Now that you have completed the install of EOS Easy Contract it is now time to start building your first smart contract.
> EOSEasyContract.exe template new --path %USERPROFILE% --name pongpingpong
code %USERPROFILE%\pongpingpong
Hit Ctrl-Shift-B
to build the sample contract
Now in the build directory you should be able to see the wasm and abi files
In this case it is EOSCDT-CB6FACF96E87DAA7FAB531911B0B8683
Hit Ctrl-Shift-\`
to open a terminal
docker exec -it EOSCDT-CB6FACF96E87DAA7FAB531911B0B8683 /bin/bash
The below steps are captured in a script that can be copied to the machine and run.
# send output to a log file and start a background process
nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin &> /var/log/nodeos.log &
tail /var/log/nodeos.log
# create wallet named "default"
cleos wallet create --file /tmp/default.w
# import the default private key
cleos wallet import --private-key 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
# the wallet will lock occasionally so you would need to unlock it
cleos wallet unlock --password `cat /tmp/default.w`
cleos set contract eosio /opt/eosio/contracts/eosio.bios/ -p eosio@active
For the sake of this tutorial we are using the default key. DO NOT USE THIS KEY FOR ANYTHING BUT DEVELOPMENT
# create the account
cleos create account eosio pongpingpong EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
# check the account
cleos get account pongpingpong
# load up the wasm file
cleos set code pongpingpong /data/build/pongpingpong.wasm
# load the abi
cleos set abi pongpingpong /data/build/pongpingpong.abi
cleos push action pongpingpong hi '{"user" : "pongpingpong"}' -p pongpingpong