Skip to content

Write and build a smart contract

Node, CLI, and RPC examples target FullOn Core v0.9.2. Contracts, CDT, and wallets have independent versions; their stated verification scope does not automatically change with Core. See version baseline and migration.

Toolchain

Choose a compatible toolchain from the official CDT repository and releases. Installation varies by platform/version. The installed cdt-cpp --version returned 0.9.0 during verification; this is not a recommendation for every network.

Minimal C++ contract

Create hello.cpp:

#include <eosio/eosio.hpp>

class [[eosio::contract("hello")]] hello : public eosio::contract {
public:
    using eosio::contract::contract;

    [[eosio::action]]
    void hi(eosio::name user) {
        eosio::require_auth(user);
        eosio::print("Hello, ", user);
    }
};

require_auth(user) requires authorization from that account. This example prints text only; it does not persist data or transfer assets.

Compile

cdt-cpp --version
mkdir -p build
cdt-cpp -abigen -contract hello -o build/hello.wasm hello.cpp

Confirm build/hello.wasm and build/hello.abi exist. The ABI should contain action hi with parameter user. Record compiler version, source commit, and build command for reproducibility.

Test

On an isolated chain or testnet, verify valid authorization succeeds, missing authorization fails, and ABI parameters are correct. More complex contracts also need table migrations, integer boundaries, resource usage, repeated calls, and external notifications checked. Compilation alone does not establish safety or production readiness.

Next: deploy and call actions.

Sources: CDT, its examples/hello, and the local compilation check.