Structuring Your Contract

The way you structure your smart contract is really a matter of personal preference. However, I've created a boilerplate contract with the structure that I personally use.

You don't have to use my structure, but if you're stuck and don't know where to start, this can be helpful for you. The boilerplate contract is located at the following Github URL.

Note: Standard header files, and files that are not in the main directory can be included using <angle brackets>. Other files will need to use a relative path in quotation marks (i.e. #include "somefile.cpp") During compilation, you will need to specify any non-standard directories that you want files to be included from if you use angle brackets, using the -I flag. e.g. eosio-cpp -I directory_to_include boiler.cpp -o boiler.wasm --abigen

As I mentioned, this is all a matter of personal preference. Many contract developers like to keep all of the logic in 1 or 2 files, as you can see with something like the AtomicAssets Contract.

My personal preference - especially since my contracts can grow quite large, is to separate different purposes into different files. I like having contract actions in 1 file, regular functions in another file, constants in another file, etc.

Last updated