WAX-CDT Sample Contracts
WAX-CDT provides a wax-cdt/examples directory that includes the following sample smart contracts:
- Hello World
- multi_index Example
- Inline Transaction Example
Each project includes two CMakeLists.txt files: one in the project's root directory, and the other in the projects src directory. You can use these files to automatically generate WASM and ABI files for the sample projects.
In this tutorial, you'll learn how to use the make scripts to build the Hello World example.
Compile Hello World
To compile the Hello World example:
From the command line, navigate to wax-cdt/examples/hello.
cd wax-cdt/examples/hello
Create a build directory.
mkdir build
noteNote: By default, eosio-init creates a build directory. Because this directory is empty, it's not uploaded to Git. If you use eosio-init to [Create a Smart Contract](/docs/dapp-development/wax-cdt/cdt_use.html#compile-hello-world), you'll be able to skip this step.Navigate to the build directory.
cd build
Initialize cmake from the wax-cdt/examples/hello directory to write the necessary build files to the build directory.
cmake ..
The console prints the following build tasks:
-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 7.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Setting up Eosio Wasm Toolchain 1.6.1 at /usr/local/eosio.cdt
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.10)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done
-- Generating done
-- Build files have been written to: waxblockchain/wax-blockchain/wax-cdt/examples/hello/buildBuild the scripts.
make
The console prints the following confirmation:
[ 5%] Performing build step for 'hello_project'
[100%] Built target hello
[ 11%] No install step for 'hello_project'
[ 16%] No test step for 'hello_project'
[ 22%] Completed 'hello_project'
[ 50%] Built target hello_project
[ 55%] Performing configure step for 'hello_tests_project'
You should now be able to locate the hello.wasm and hello.abi files in the build/hello directory.