2

I have EOS running on Docker and can run cleos successfully. my next step is to deploy the token contract but looking in the ./contracts/eosio.token directory I don't see a .wast file.

I could create it with eosiocpp but I don't seem to have it installed. so, as per the Docker wiki, I ran the docker build in the Docker/dev directory, which created an image eosio/eos-dev

now my question: how do I run eosiocpp to create the WAST file in my filesystem using Docker?

2
  • How about, if you use one of the prebuild docker images? You can you try to get the docker-image from: hub.docker.com/r/eosio/eos-dev/tags It includes eosiocpp.
    – ChrisD
    Commented Jul 18, 2018 at 3:35
  • thanks but my question is: how do I use it?
    – ekkis
    Commented Jul 19, 2018 at 17:20

2 Answers 2

3

I would also recommend using the docker image from docker-hub.

Pull it by running the following command:

docker pull eosio/eos-dev

Now you create a folder in your local machine named Code Afterwards you can start the container by running it with the following command. This will use your local Code folder and mount it to the filesystem in the docker container.

docker run --rm --name eosio -d -p 8888:8888 -p 9876:9876 -v <path_to_code>/Code:/Code -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"

Afterwards you use aliases for calling cleos and eosiocpp.

alias cleos='docker exec eosio /opt/eosio/bin/cleos --wallet-url http://localhost:8888'

alias eosiocpp='docker exec eosio /opt/eosio/bin/eosiocpp'

Now you can start developing and if you want to compile your code you can call the eosiocpp alias with your mycontract.cpp file.

eosiocpp -o Code/mycontract.wast Code/mycontract.cpp
eosiocpp -g Code/mycontract.abi Code/mycontract.cpp

Pushing it to the chain can be done by using cleos alias with:

cleos set contract mycontract Code/mycontract Code/mycontract.wast Code/mycontract.abi

For debugging the container this might also help. Which gives you a terminal inside the container.

docker exec -i -t eosio /bin/bash

And viewing logs with:

 docker logs --tail 100 eosio
5
  • fantastic. I noticed that the developer portal recommends running EOS the way you indicate but there's a problem: keosd doesn't run and you can't create accounts. the Docker wiki offers a better solution: download the docker-compose.yml and then start both services. the only thing is eos-dev is not included, though something called eosio/builder is, which seems to be the same thing. thank you for the complete reply. it will help anyone else trying to do this
    – ekkis
    Commented Jul 19, 2018 at 17:25
  • the container start failed, curiously, not leaving any trace (docker ps -a came up empty). running it with -it I had a chance to see the message "database dirty flag set (likely due to unclean shutdown): replay required". I know how to fix it but I'm wondering why this would happen given that I removed all containers and all images from Docker before starting on your instructions
    – ekkis
    Commented Jul 20, 2018 at 19:46
  • also, publishing the contract fails with "Reading WAST/WASM from Code/eosio.token.wast... Assembling WASM... Publishing contract... Error 3200006: invalid http request Error Details: The server has rejected the request as invalid! Please verify this url is valid: localhost:8888/v1/wallet/get_public_keys If the condition persists, please contact the RPC server administrator for localhost!" -- I'm wondering whether it's because I need to create a wallet first, for which I need keosd?
    – ekkis
    Commented Jul 20, 2018 at 19:59
  • Abour your first error this is hard to tell because I don't your setup and this maybe some docker specific. About the second error: yes you need the keys for that account and a wallet.
    – tmm
    Commented Jul 20, 2018 at 20:34
  • 1
    as breadcrumbs, I figured out the whole Docker workflow. documented it here: medium.com/@ekkis/eos-development-on-docker-3f4eb9b680ec
    – ekkis
    Commented Jul 21, 2018 at 4:16
2

If you do not have special reason to use your current docker image. It is better to use docker image included in eosjs. eosio.token contract is already deployed when running this docker.

https://github.com/EOSIO/eosjs/tree/master/docker

In addition, I recommend that building your own contract in your eos repository and copy result to the docker.

$ docker cp /your workspace/eos/contracts/your contract/ docker_keosd_1:contracts/your contract/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.