An EOS.IO Developer's Notes - How To Publish A Contract to the Public Testnet
Written by: Gunnar Pope on 2/21/2017
https://github.com/gunnarpope
Hey Steemians and EOS developers!
Here are the notes I recorded when learning how to publish the EOS.IO currency contract to the Public Testnet. I'm posting this in response to @jjcali question on how to run the eos node and to help grow the @eos community. I learned how to do all of this from reading the EOS github Tutorials here: https://github.com/EOSIO/eos/wiki/Tutorials.
Some of these commands may be outdated with the new migrations to the Dawn 3.0 code, but I hope it helps someone out there (just one person would make me happy!) learn how to use the terminal and run the EOS blockchain.
If you enjoy, please support me as a developer! I'm a biomedical engineering student and have about 3 blockchain dapps I would like to (rapidly) develop but I can only get to write code in my free time at night. For EOS to really rocket to the moon and realize its full potential, we need need every developer we can find, from experienced developers to newbies, to start applying EOS dapps across a range of real-world applications. Then the world will finally understand what our excitement is all about.
Enjoy!
Gunnar
Please upvote @powderskier on Steemit to support!
Or Donate!
BTC: 35fLcnnsUFDRp4fW3d7GLBTdEtyGR8SY7g
LTC: MC85Gqxaj5sBxKSui54VbKTypUie4Rrng
Ok, let's start the wallet
$ cd /eos/build/programs/eos-walletd && ./eos-walletd
1453521ms wallet_plugin.cpp:34 plugin_initialize ] initializing wallet plugin
1453521ms http_plugin.cpp:138 plugin_initialize ] host: 127.0.0.1 port: 8888
1453522ms http_plugin.cpp:141 plugin_initialize ] configured http to listen on 127.0.0.1:8888
1453522ms http_plugin.cpp:153 plugin_startup ] start processing http thread
1453522ms http_plugin.cpp:210 plugin_startup ] start listening for http requests
1453522ms http_plugin.cpp:215 plugin_startup ] http io service exit
1453522ms wallet_api_plugin.cpp:69 plugin_startup ] starting wallet_api_plugin
1453522ms http_plugin.cpp:239 add_handler ] add api url: /v1/wallet/create
1453522ms http_plugin.cpp:239 add_handler ] add api url: /v1/wallet/get_public_keys
1453523ms http_plugin.cpp:239 add_handler ] add api url: /v1/wallet/import_key
1453523ms http_plugin.cpp:239 add_handler ] add api url: /v1/wallet/list_keys
1453523ms http_plugin.cpp:239 add_handler ] add api url: /v1/wallet/list_wallets
1453523ms http_plugin.cpp:239 add_handler ] add api url: /v1/wallet/lock
1453523ms http_plugin.cpp:239 add_handler ] add api url: /v1/wallet/lock_all
1453523ms http_plugin.cpp:239 add_handler ] add api url: /v1/wallet/open
1453523ms http_plugin.cpp:239 add_handler ] add api url: /v1/wallet/set_timeout
1453523ms http_plugin.cpp:239 add_handler ] add api url: /v1/wallet/sign_transaction
1453523ms http_plugin.cpp:239 add_handler ] add api url: /v1/wallet/unlock
Open a new terminal and move into eosc folder to use .eosc
$ cd eos/build/programs/eosc/
Open a wallet named gptestnet
eosc:$ ./eosc wallet open -n gptestnet
Opened: gptestnet
eosc$ ./eosc wallet list
Wallets:
[
"gptestnet"
]
Unlock the wallet
eosc$ eosc wallet unlock -n gptestnet
password: Unlocked: gptestnet
eosc$ eosc wallet list
Wallets:
[
"gptestnet *"
]
Learn how to get an account as an eos.io developer here:
https://github.com/EOSIO/eos/wiki/Testnet:-Public#accounts-on-testnet
My account is called powderskier.
Connect eosc to the testnet
$ eosc$ ./eosc -H testnet1.eos.io -p 80 get account powderskier
{
"account_name": "powderskier",
"eos_balance": "100.0000 EOS",
"staked_balance": "0.0001 EOS",
"unstaking_balance": "0.0000 EOS",
"last_unstaking_time": "1969-12-31T23:59:59",
"permissions": [{
"perm_name": "active",
"parent": "owner",
"required_auth": {
"threshold": 1,
"keys": [{
"key": "EOS7gUMtWH1TEW31v8rXCe6zYajqUo46qH22CQN6PX4nzMzJZkUhS",
"weight": 1
}
],
"accounts": []
}
},{
"perm_name": "owner",
"parent": "",
"required_auth": {
"threshold": 1,
"keys": [{
"key": "EOS7gUMtWH1TEW31v8rXCe6zYajqUo46qH22CQN6PX4nzMzJZkUhS",
"weight": 1
}
],
"accounts": []
}
}
]
}
Add an alias for the eosc settings to allow you to type $ eosc get code powderskier
instead of eosc -H testnet1.eos.io -p 80 get code powderskier
echo "alias eosc='eosc -H testnet1.eos.io -p 80'" >> ~/.bash_aliases
$ source ~/.bash_aliases
Before uploading a contract, verify that there is no current contract:
eosc$ eosc get code powderskier
code hash: 0000000000000000000000000000000000000000000000000000000000000000
Complete the build process by running build install. This will create all the binaries needed to run eosc, eoscpp, eosd, etc...
$ cd ~/eos/build && make install
Add the executables to my path
$ cd eos/build/install/bin
bin $ ls
abi_gen codegen embed_genesis eos-walletd eosc eoscpp eosd launcher
add the path to the eos binaries to your $PATH variable. (This step is no longer necessary after running the new eos build script, but I'll leave it here for reference purposes.)
bin$ echo "export PATH=$PATH:eos/build/install/bin" >> ~/.bash_profile
bin $ source ~/.bash_profile
Ok, I've had trouble compiling the .wast file and cant find a way to fix the include path of the compiler. Use this directory to adjust the compile path
bin $ pwd
eos/build/install/bin
bin $ ls
abi_gen applesedemo codegen embed_genesis eos-walletd eosc eoscpp eosd eosio-walletd eosioc eosiod launcher
Looks like the new wallets are stored here:
$ cd eos/data-dir
data-dir $ ls
config.ini gptestnet2.wallet
This location is subject to change so you may want to use$ sudo find / -name data-dir
to find this folders location.
Open and unlock the gptestnet walletd
eosc$ ./eosc wallet unlock -n gptestnet --password XXXXXXXXXXXXXXXXXXXXXXXXXXXX
Unlocked: gptestnet
eosc$ ./eosc wallet list
Wallets:
[
"gptestnet *",
"gptestnet2 *"
]
Now, connect to the testnet and upload the currency contract
$ ./eosc -H testnet1.eos.io -p 80 get account powderskier
or use the alias we created earlier to execute the same command:
$ eosc get account powderskier
Yes! I was able to publish the exchange.wast contract!
eosc$ ./eosc -H testnet1.eos.io -p 80 set contract powderskier ../../contracts/exchange/exchange.wast
Reading WAST...
Assembling WASM...
Publishing contract...
{
"transaction_id": "626d913dab6c1379d6126d362f5b6e78f9109d9b4b62b1bc6d79c68138077540",
"processed": {
"ref_block_num": 63806,
"ref_block_prefix": 1190020872,
"expiration": "2018-01-29T03:51:50",
"scope": [
"eos",
"powderskier"
],
"signatures": [
"2028f38347a2c550a5fc0ce2d676452667e7129b9581bcb8a33bdaf203bdea037141a1c05dfa410eaf1dc470748bd9345b5c8c9900e6d07b1a267d28618841fcbc"
],
"messages": [{
"code": "eos",
"type": "setcode",
"authorization": [{
"account": "powderskier",
"permission": "active"
}
],
"data": {
"account": "powderskier",
"vm_type": 0,
"vm_version": 0,
"code": "0061736d01000000015b0f60057e7e7e7f7f017f60027f7f0060017f0060037e7e7f017f60047e7e7f7f017f60017e006000017f60027f7f017f60037f7f7f017
...
Good luck with your own developments and send me a comment or share your EOS developer experiences. I'd love to hear about your experiences. I'm hear to help launch the distributed computing movement to improve trust, privacy, security, and relationships in the digital world and please let me know how I can help.
-Gunnar
Thank you so much for putting this together. I'm now following you. Looking forward to more great content.
Excellent @jjcali! I'll try to put together another tutorial this week.
Stupid newbie questions, are you running this on a local machine that you have or a cloud server? If it is a local machine what is your configuration? Is there a minimum connection speed required? I have a plain DSL account that currently is currently not so great on the upload side. Will that be a problem just getting something started and allow my continued learning?
Thanks for the help.
I'm one so you can be HAPPY!
SDG
Thanks for the support, SDG! It feels amazing to lend a hand to this community.
Here's my feedback:
In order to interact with the public testnet, you need to start running a local node using the ./eosd (or ./eosiod) command. I think about this like opening a communication portal between you and the blockchain. Once ./eosd is running, you can start sending actions to the eosio blockchain using the ./eosc (or ./eosioc) command which allows you to publish contracts, execute a contract, etc.
Try getting just the .eosd and .eosc working and see if you can connect ( or 'ping') the testnet blockchain using the following command:
$ ./eosc -H testnet1.eos.io -p 80 get account powderskier
Once you can do that simple test case, you just confirmed that you can send commands and retrieve data from the eosio blockchain (and you know that your connection speed can handle the basic use case of running a node.) From there, try to publish a simple example dapp and grow your application from there.
-Gunnar
Great tutorial :)
Also you can check that the contract is there using the EOS tracker => . https://eostracker.io/accounts/powderskier :)
Nice app @kesarito! That's the first time I've been there and was amazed at how quickly you can see the total transaction history of the account. That's the beauty of blockchain tech I suppose. Keep it up, @kesarito.
This is fantastic, great work.
Here's a couple of notes to help you along :)
./bashrc
has some logic for a separate aliases include which used to need to be manually uncommented but is defaulted to enabled now so you could change that line toecho "alias eosc='eosc -H testnet1.eos.io -p 80'" >> ~/.bash_aliases
so that it doesn't pollute a potentially existing./bash_profile
.Notice i've also removed the
./
since after you runcd /eos/build && sudo make install
theeosc
binary is put into the PATH. ( "add the path to the eos binaries to your $PATH variable" also shouldn't be necessary anymore )The
data-dir
is subject to change based on whether you're running a local node or not. Your best bet would be to dosudo find / -name data-dir
and grab the location from there, for instance mine is at:/home/eos-test-box/eos/build/programs/eosd/data-dir
Thank you for your advice, @nsjames! I've edited the post to include your suggestions and thank for your feedback.
Thanks for sharing these notes. Keep doing it as it can help someone.
This feedback really helps me craft my next batch of content to publish on @steemit and @eos development and I appreciate it.
Did you compare the ease of development with neo / iota / ethereum?
I actually started with ethereum and tried that for a month and came to the realization that their platform has some serious development pitfalls. Mainly:
At this point, I started looking at around for companies that could address the scalability problem as well as be developer friendly. I settled on becoming an EOS developer because I believe in their vision, team, their C++ based dev language choice, and their working track record with Bitshares and Steemit. I'm all in on these guys and can't wait to see what grows out of the EOS platform.
Resteemed
Resteemed as well
Awesome @lior-h. Thank you for the support.
-Gunnar