The first EOS Developers Meet-up in Sofia, Bulgaria is a fact.
On the 5th of September, we held the first EOS Developers Meet-up. The main theme was “First Steps in EOS Blockchain Development”. During the event, we had a Live Demo where we created a simple Factory for creating robots on the EOS Blockchain.
You can download the presentation from the event from this link.
Here you can find a brief overview of the demo. The code can be found in our GitHub. We used the latest EOSIO version (1.2.3).
Note: You should first clone and build the EOSIO repo, and then run the nodeos which will start a local node.
Let’s continue with the code. As I said we’re going to create a Robot Factory. Add two files in your project folder:
RobotFactory.hpp – the header file
RobotFactory.cpp – the implementation file
The header file
The header file will contain all variables, constants, and functions referenced by the implementation file. This way the project structure and code is more organized and follow the High-Quality Code principles.
I should note here that we’re using a struct called “robot”. In EOSIO this is the way we declare and use tables. They keep our data. When you want to use the type “robot” as a parameter in your action (in our case create) you should declare the struct before its first using.
We have 4 main actions: create, update, getbyid and remove. Their implementation will be inside the RobotFactory.cpp. Let’s continue with it.
The implementation file
The implementation file contains all actions declared in the header.
I won’t get into details as we have awesome documentation of the code 🙂
As a next step, we need to deploy and test the smart contract. However, we need to create a wallet and an account first.
Creating a wallet
The wallet can be thought of as an encrypted repository of public-private key pairs. These are needed to sign operations performed on the blockchain. To create a new wallet execute the following command:
Each wallet contains public-private key pairs. We need to generate this keys and import them into the wallet
Creating an account
Once we have all the keys imported is time to create our new account which we’ll use to deploy the smart contract. The command is
Deploying EOS Smart Contract
Awesome! Now it’s time to deploy the EOS smart contract. For its deployment, we need two files WAST & ABI. You can generate them with the following commands:
The deploying is pretty easy
So, now we have our first EOS smart contract deployed on the EOS Blockchain. Let’s test it. You can use the following commands which will trigger our actions:
If you’re just starting with EOS Blockchain Development check our tutorials:
- First Steps in EOS Blockchain Development
- The ultimate end-to-end EOS dApp Development tutorial – Part 1
- The ultimate end-to-end EOS dApp Development tutorial – Part 2