/eos-simplepacman-contract

Starting contract for EOS Spore mini game built for Blockchain Developer Philippines' EOS session

Primary LanguageWebAssemblyMIT LicenseMIT

This repo was built with examples from ff links:

Instructions:

Setup EOS Node

  1. docker pull eosio/eos-dev

  2. sudo docker run --rm --name eosio -d -p 8888:8888 -p 9876:9876 -v /tmp/work:/work -v /tmp/eosio/data:/mnt/dev/data -v /tmp/eosio/config:/mnt/dev/config eosio/eos-dev /bin/bash -c "nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::wallet_plugin --plugin eosio::producer_plugin --plugin eosio::history_plugin --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin --plugin eosio::http_plugin -d /mnt/dev/data --config-dir /mnt/dev/config --http-server-address=0.0.0.0:8888 --access-control-allow-origin=* --contracts-console"

  3. sudo docker exec -i -t eosio /bin/bash

  4. vi mnt/dev/config/config.ini

  5. (Change) "http-validate-host = 1" to "http-validate-host = 0"

  6. View node outputs: docker attach eosio

Clone EOS Spore contract, marvel at the code/get confused

  1. Open new terminal

  2. mkdir eos-contract

  3. cd eos-contract

  4. git clone https://github.com/MNLBlockDevs/eos-simplepacman-contract

  5. cd eosspore/contracts

Compile (generate ABI and WAST files)

  1. eosiocpp -o ./spore/spore.wast spore.cpp

  2. eosiocpp -g ./spore/spore.abi spore.cpp

Create your wallet on the EOS node, so we can test it out!

  1. cleos wallet create -n TEXT=chris

  2. cleos wallet unlock -n TEXT=chris

  3. cleos create key

  4. store the wallet password, public key and private keys

  5. cleos wallet import --private-key [private key]

  1. cleos wallet import --private-key 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3

Deploy to the single node test net

  1. cleos create account eosio spore.ctr [public key]

  2. cleos set contract spore.ctr ./spore -p spore.ctr

  3. cleos create account eosio tester [public key]

Try it out!

  1. cleos push action spore.ctr createentity '["tester", 0, "blue", 0]' -p tester

  2. cleos push action spore.ctr moveentity '["tester", 0, 10, 10]' -p tester

  3. cleos push action spore.ctr killentity '["tester", 0, 0]' -p tester

Next: Build the web app!

Notes:

  • Python 2.7
  • Latest Node

cd back to eosspore

cd ..

install dependencies

npm install

serve with hot reload at localhost:8080

npm run dev

build for production with minification

npm run build

serve your production build at localhost:5000

npm run serve