cleos
, it is now time for us to build our first Telos smart contract!eosio-init -version
, which should output the version number of the softwarehelloWorld
, then cd helloWorld
into the folder.eosio-init -project helloWorld
. This will create the basic source code needed to create a simple "hello world" smart contract that we will be able to publish onto the blockchain. The name of the contract is determined by the term following the -project
text, so our contract will be entitled helloWorld
. The basic folder structure should look something like the following:build
: this is where the compiled final files will be generated that we will push to the blockchain. The folder should start off emptyinclude
: the header files that will be referenced in the C++ source codericardian
: this folder is for Ricardian Contracts, which are outside of the scope of this tutorial, but are typically used in parallel with smart contracts to help clarify the contract's intent. We will ignore this folder for now.src
: the source C++ files that will dictate the behavior (actions) of our smart contract. It also starts off with a CMakeLists.txt
file which helps to configure the compilation process (this file can be ignored for now)README.txt
: directions on how to build and publish the smart contractinclude/helloWorld.hpp
and src/helloWorld.cpp
. Let's start with the header file:eosio/eosio.hpp
header file that includes many tools that will make our lives easier. It then uses the eosio
namespace to make our syntax cleaner. The contract helloWorld
is a class extending the eosio::contract
class. Inside of the class we use the eosio::contract::contract
namespace and then declare the action hi
which will take in a parameter nm
of type name
. Note that the ACTION
syntax is a macro imported from the eosio/eosio.hpp
and represents a type of function.src/helloWorld.cpp
:hi
on the helloWorld
class. Again, the ACTION
syntax is a macro for a function. The method takes in nm
which is of type name
. Inside of the method, a simple string Name : someName
is printed to the console output for any full node that processes this smart contract action.brew install make && brew install cmake
for MacOS and sudo apt-get -y install cmake
for Ubuntu. Once they are installed, navigate to the build
directory with cd build
and then cmake .. && make ..
. You should then see the following folders created within the build
directory: CMakeFiles
, helloWorld
, and helloWorld_project-prefix
.cleos set contract
and the documentation we have for it is the following: