EOS Contracts Noob Troubleshooting Tech Note #1: Loading the token contract
TL;DR...
Instead of cleos set contract eosio.token build/contracts/eosio.token -p eosio.token@active
Run cleos set contract eosio.token /contracts/eosio.token -p eosio.token@active
Context
These posts are not for the readers of my newsletter. These are highly technical in nature and EOS Contracts specific.
I'm going to share the solutions to the bumps in the road I hit as I come up to speed on writing EOS Contracts.
Let's Dive In
First, please note the date this was written. This stuff changes really fast, and if you're reading this a few months from now, and this article isn't solving your problems, look for a more recent article that takes into account the most recent changes...
Today, I'm going to start with a super simple/minor issue that stumped me for a while before I realized it wasn't me. :) The EOS Developer Portal at developers.eos.io in the Introduction to the EOSIO Token Contract page, says to run the following (2nd code snippet)
cleos set contract eosio.token build/contracts/eosio.token -p eosio.token@active
Now, at this point, if you've followed the tutorial, you're using the docker eosio-dev container, which is recommended. This is distinct from compiling all the source code. Now, compiling from source is valid and makes all this a bit more clear by giving you a flat, naked filesystem to work with (taking docker out of the way), but given that requires 20 GB of disk space (more than I have on my VM atm) and the tutorial specifically recommends the docker image for development, I'm going to point out a tiny detail that's basically wrong in the tutorial, given the use of the docker image...
When the above command references build/contracts/...
, the build
part is wrong. If you root around in the docker image, you find that there is no build folder, but there is a contracts folder mapped into the path of the container.
If you don't know how to "root around" in your docker image, once you're got your docker-based node up and running according to the tutorial, you can run commands (such as the ls
command illustrated below) within the docker image with either
docker exec -it eosio ls
or
docker exec eosio bash -c ls
So simply removing build
from that path has everything work because the resulting command
cleos set contract eosio.token /contracts/eosio.token -p eosio.token@active
refers to the path /contracts/eosio.token
, which does exist in the docker volume.
Also, while I'm not sure this was critical to my success, I did find this link, which said I needed to refresh my docker image, which I did. So if the above doesn't solve your problem, try
docker pull eosio/builder:latest
If you started the tutorial / pulled this image after 07 May 2018, it shouldn't be necessary, but just in case...
Hope my suffering saves someone some suffering of their own.
Go EOS!