EOS Easy Contract allows EOS developers to get started writing smart contracts in minutes, not hours!
EOS Easy Contract allows you to create a smart contract without having to compile any software and does not require knowledge of the complex EOS ecosystem used to build its contracts.
EOS Smart Contracts are written in C++, and configuring a development environment to compile those smart contracts can be time consuming and much of the tooling is not yet available for Windows developers.
How does EOS Easy Contract pull this together? First, all of the tooling needed is packaged into a Docker container. When it comes time to compile your code, EOS Easy Contract runs all the needed commands inside the docker container and gives you back the result (.wasm file) which can then be uploaded to the EOS network.
EOS Easy Contract provides tooling to quickly:
- Create a starting Visual Studio Code template.
- A watcher application that will build your code every time you save.
- Allow Visual Studio Code to report errors back in a helpful way.
Currently Supported on: Windows, OSX (coming soon), Linux (coming soon)
IMPORTANT! Docker is a requirement, as per the Docker install requirements (https://docs.docker.com/docker-for-windows/install/), you need at minimum Windows 10 Pro.
- Windows 10 64bit: Pro, Enterprise or Education (1607 Anniversary Update, Build 14393 or later).
- Virtualization is enabled in BIOS. Typically, virtualization is enabled by default.
Here's how to check your windows version:
- Hit the "Windows Key" and Type "This PC"
- Right click on "This PC" in the menu
- Select Properties
- Look at what's displayed under the Window Edition heading
While there are ways to work around this (eg. if you have Windows 10 Home you can use https://docs.docker.com/toolbox/toolbox_install_windows/), we do not support / test this method.)
Docker is becoming such an essential tool for developers that we really feel that you'd be doing yourself a favor by upgrading to Windows 10 Pro. The upgrade should cost about $50 and will save you many many hours of frustration ... it's money well spent and is a simple upgrade process:
- Purchased upgrade license key from your vendor of choice
- https://support.microsoft.com/en-us/help/12384/windows-10-upgrading-home-to-pro
*** Check that your CPU supports Virtualization before upgrading. Most new CPUs do.
- Docker (free) - https://www.docker.com/get-started
- Visual Studio Code (free) - https://code.visualstudio.com/download
Explainer Video (Click Below)
Download ( https://github.com/eosnewyork/EOSEasyContract/releases ) and decompress the software (in this example we'll decompress the .zip file to a folder c:\tools\EOSEasyContract)
This step added the exe folder to your PATH variable.
# Your command prompt must have Admin rights as this will try to add a variable to your PATH
> cd c:\tools\EOSEasyContract
> EOSEasyContract.exe init windows
Before executing the following commands, ensure that you this following setting is set correctly in your docker settings.
The following command will check that you have the required Docker image. If not, it'll be downloaded .. it is a large image (~3GB) and takes some time to download.
> cd c:\tools\EOSEasyContract
> EOSEasyContract.exe init docker
By executing the following, the header files in the docker container are copied to the local machine (C:\eosincludes folder) and will be referenced in the generated templates. This allows Visual studio code completion and other functions to act correctly in context.
> EOSEasyContract.exe init include
To generate a new project use the the following command.
In the below example we will create a project called "EOSTemplate1" in the C:\temp folder. Note that c:\temp must exist and the project folder (EOSTemplte1 in this case) will be created.
> EOSEasyContract.exe template new --path c:\temp --name EOSTemplate1
6. Open the project in Visual Studio Code, using the below instruction or simply launch the GUI and open the folder
> cd c:\temp\EOSTemplate1
> code .
You should see output that looks as follows in your Visual Studio termnal window.
> Executing task: EOSEasyContract.exe build --path "C:\temp\EOSTemplate1" --watch <
Begin watching C:\temp\EOSTemplate1. Build using docker image XXXXXXXXXXXXXXXXX.
You should see somethin like this in the terminal window:
=========== Building eosio.contracts ===========
-- Setting up Eosio Wasm Toolchain
-- Configuring done
-- Generating done
-- Build files have been written to: build
Scanning dependencies of target EOSTemplate1.wasm
[ 50%] Building CXX object CMakeFiles/EOSTemplate1.wasm.dir/EOSTemplate1.cpp.o
[100%] Linking CXX executable buddy1.wasm
[100%] Built target EOSTemplate1.wasm
End EOSIO contract build
Done Building. Build Duration = 00:00:08.0230652
C:\temp\EOSTemplate1\EOSTemplate1.wasm
Getting a test EOS Network up and running is currently outside the scope of this readme.
The following steps can however be used to push your newly compiled contract to a testnet or mainnet of your choice.
Check the Terminal output which compiled your contact and you'll find a container name that looks as follows: EOSCDT-XXXXX (Example: EOSCDT-7BB4BB304C3DE98597913F1FDD1386EC) - This is the name of the docker container that was created to compile your contract.
Run the following command to gain shell access to the running container.
docker exec -it {Container Name} /bin/bash
Next create a wallet and import the private key for the account you'd like to publish the contract to.
cleos wallet create --to-console
cleos wallet import --private-key {Account Private Key}
Upload the contract to your EOS account
cleos -u {API URL}:{API Port} set contract {EOS Account Name} /data/build {Contract Name}.wasm {Contract Name}.abi -p {EOS Account Name}
Call an action on your contract. This example assumes you've uploaded the default template and that a method name 'Hi' exists.
cleos -u {API URL}:{API Port} push action {EOS Account Name} hi '["username1"]' --permission {EOS Account Name}@active
In order to upgrade:
- Delete the current binaries from your inital install locations.
- The following command will stop any running containers.
> EOSEasyContract.exe util cleanDocker
- The docker image may have been upgraded, so run the following commadn to download any new image.
> EOSEasyContract.exe init docker
- The include files may have changed, so run the following to download the latest include files.
> EOSEasyContract.exe init include