Are you looking to start developing on EOS blockchain and become an EOS developer? Congratulations, you have landed at the right place. We created this guide for newbies and it will help you make your first steps in EOS blockchain development before moving to more advanced programming later in the series.
This guide was initially published back in April 2018 just a few months before the EOS Mainnet launch. It was the first EOS blockchain development guide ever created and it quickly became a favorite to everyone.
Because this guide is still loved so much by the community we have now completely revamped it to meet the highest standards, best practices and to use the latest version of EOSIO protocol. This is “First Steps in EOS Blockchain Development” - 2021 Edition.
What you’ll learn in this EOS blockchain development guide:
How to set up an EOS blockchain development environment
How to create and launch a single EOS blockchain node
How to create a wallet and an EOS account
How to deploy an EOS smart contract on the blockchain
How to create your own EOS token and use it
1. How to set up an EOS blockchain development environment
Let’s start by setting up an EOS blockchain development environment. This can be very easily achieved by using pre-built binaries provided by the developers behind the EOSIO protocol. Open the terminal and execute these two commands
brew tap eosio/eosio
brew install eosio
Next, we need to install the EOSIO Contract Development Toolkit (EOSIO CDT). The kit contains tools that will help us develop EOS smart contracts easier. Execute the following two commands in the terminal to install the kit
brew tap eosio/eosio.cdt
brew install eosio.cdt
After installing both binaries (eosio and eosio.cdt) you now have everything to move forward to create and launch an EOS blockchain node.
2. How to create and launch a single EOS blockchain node
To create a new EOS blockchain node open a new tab in your terminal and copy-paste the following command:
The command will automatically create your node with the predefined settings we have included. To learn more about the different parameters you can type “nodeos -help”. If you want to see the productions of blocks in real-time just execute the next command:
tail -f nodeos.log
EOS is producing blocks every 0.5 seconds. Let the node produce blocks. We’ll return back to it later.
3. How to create a wallet and an EOS account
It’s time to create your first wallet and account but before that let’s clarify what are they and why we need them.
In EOS blockchain, unlike in Ethereum, you have accounts instead of addresses. You need an account to send and receive transactions to the blockchain. Accounts are a very powerful tool in EOS because they can contain authorizations (permissions). An account can be owned by one person or by a group of people and each one can have custom permission in the account. We won’t get in details now but simply explained an EOS account dedicated to a team from an online newspaper can look like this:
Thanks to the permission structure you can specify in the smart contract who is authorized to execute specific actions and sign transactions. For example, the editor should not be able to publish a new article. The action can be executed only by the publisher.
The wallets, on the other hand, might be something you are already familiar with. They contain your keys, and you use them to sign transactions.
Now that we know what are wallets and accounts let’s create them. Create your first wallet by using the following command:
# Outputs a password that you need to save to be able to lock/unlock the wallet
# If you don't want to use the "default" wallet add: -n {your_wallet_name} at the end of your command
cleos wallet create -n mywallet --to-console
This will create a wallet named “mywallet”. We use “--to-console” to print the result on the terminal and “cleos” is a command-line tool that we installed earlier with the pre-built binaries. Once you execute the command it will print the password of the wallet. Save it because you’ll need it to lock/unlock your wallet.
By default all wallets are closed and locked. However, to be able to use them we’ll need to first open them and then unlock. You can do that by executing the following two commands:
cleos wallet open -n mywallet
cleos wallet unlock -n mywallet
The wallet should be now unlocked and ready for use. Let’s import our first key. Each new EOSIO chain has a default system account which is called eosio (the same which we used to run our node). If we want to use it for signing transactions we need to import its private key to our wallet. Execute the following command to do that:
Creating a new EOS account is pretty simple. What you need to remember is that an account can be only created by another account. This is why the default system account is needed and it’s also the reason we needed to import its private key in our wallet - we’re going to sign a transaction. The command for creating an account is:
As you can see the name of our new account is going to be nfltoken and we’re using the eosio account to create it. You might also be noticing that we need to include a public key for our new account. We need this so we can later access it and sign transactions with it. Before creating the account let’s generate a new key:
cleos wallet create_key -n mywallet
This will create a new private key and it will automatically include it in our wallet. It will also print the public key. Use it into the previous command and hit enter to create our new account.
You can verify that the account was successfully created by executing this command:
cleos get account nfltoken --json
4. How to deploy an EOS smart contract on the blockchain
It’s time to deploy our first EOS smart contract which we’ll use to create a custom token. But wait, we don’t have any smart contracts. Don’t worry about this. For this guide we’re going to use the standard eosio.token smart contract developed by the team behind EOSIO protocol. The smart contract comes out of the box with everything we need.
But first, create a folder in a place of your decision and clone the contracts repo in it.
Once you’re ready navigate to the eosio.token folder using the terminal.
In order to deploy an EOS smart contract to the blockchain, we need two things: wasm & ABI. We can get them by compiling the smart contract with one of the EOSIO contract development tools we installed at the beginning of this guide. While you’re still in the eosio.token folder executed the command:
eosio-cpp -I include -o eosio.token.wasm src/eosio.token.cpp --abigen
Ignore the warnings as they are irrelevant at the moment. You can check the folder again and you’ll find the two newly generated files.
In EOS every smart contract is associated with only one EOS account. It’s also referred to as the contract’s account. In our case, this will be nfltoken which we created earlier. Deploy the smart contract by executing the following command:
In the command above we use permission called active “nfltoken@active”. We mentioned earlier that an account can contain permissions. In this case, we use the “active” permission which is a default one for each EOS account.
5. How to create your own EOS token and use it
The moment to create a custom token and use it finally came. Our contract is deployed on the blockchain (our local node) and we can use our account to execute actions from it.
The command above executes an action called “create” from our deployed contract nfltoken. If you’re wondering why we use nfltoken twice the answer is simple. When we deployed the smart contract using nfltoken account the contract became part of it. nfltoken is still an EOS account but now it also contains our deployed smart contract. By using “push action” with “nfltoken” we say that we want to access the deployed smart contract inside this account and use the contract’s actions. In our case that’s “create”.
Execute the command and then execute the next two commands below. They will issue the tokens and then transfer some amount to the eosio account
cleos push action nfltoken issue '[ "nfltoken", "1000.0000 NFL", "my first issue" ]' -p nfltoken@active
cleos push action nfltoken transfer '[ "nfltoken", "eosio", "35.0000 NFL", "my first transfer" ]' -p nfltoken@active
Finally you can check the balances of both nfltoken and eosio:
cleos get currency balance nfltoken eosio NFL
cleos get currency balance nfltoken nfltoken NFL
This is the end and you just made your first steps in EOS blockchain development. Congratulations! You are now ready to level up with more advanced EOS blockchain concepts. Stay tuned for the next guide.
Dimo Dzhurenov brings unique symbiosis uniting vast technical experience with deep business and market knowledge. This unparalleled blend allows him to deliver valuable expertise to his team in building new and innovative decentralized solutions.
Are you looking to start developing on EOS blockchain and become an EOS developer? This guide was created for newbies and it will help you make your first steps in EOS blockchain development before moving to more advanced programming later in the series.