Skip to content

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.

WARNING

Note: These samples were created with eosio-init (part of the WAX-CDT Options suite of tools). Refer to Create a Smart Contract to customize these scripts for your smart contracts.

Compile Hello World

To compile the Hello World example:

  1. From the command line, navigate to wax-cdt/examples/hello.

    shell
    cd wax-cdt/examples/hello
  2. Create a build directory.

    shell
    mkdir build

WARNING

<strong>Note:</strong> By default, <strong>eosio-init</strong> creates a build directory. Because this directory is empty, it's not uploaded to Git. If you use <strong>eosio-init</strong> to [Create a Smart Contract](/build/dapp-development/wax-cdt/cdt_use.html#compile-hello-world), you'll be able to skip this step. 
  1. Navigate to the build directory.

    shell
    cd build
  2. Initialize cmake from the wax-cdt/examples/hello directory to write the necessary build files to the build directory.

    shell
    cmake ..

    The console prints the following build tasks:

    shell
    -- 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/build
  3. Build the scripts.

    shell
    make

    The console prints the following confirmation:

    shell
    [  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.