EOSIO.CDT Version 1.6.0: Building Towards a More Seamless Contract Development Experience

eosio
6 min readMar 22, 2019

--

As a contributor to the development and enhancement of the EOSIO™ software, we are pleased to confirm that a stable release is available for EOSIO.CDT. More details about EOSIO.CDT v1.6.0 are available in the GitHub repository. Documentation, as always, is updated on the EOSIO Developer Portal.

We are actively engaged in how businesses are building applications on the EOSIO software, which underpins our continual efforts to improve the developer experience with EOSIO. In this release, we focus on our intention to create a more seamless experience developing smart contracts by providing automation, debugging tools, and new features to facilitate what we believe to be best practices in development.

Continue reading below for the features updated in EOSIO.CDT:

Highlights in EOSIO.CDT v1.6.0

Auto-Generated Dispatcher

With the release of EOSIO.CDT v1.6.0, when writing smart contracts for EOSIO, you no longer need to manually add a dispatcher or use the EOSIO_DISPATCH macro. The dispatcher will be created for the contract based on actions, notify handlers, pre_dispatch hook and post_dispatch hook. What this new feature does is it allows for the naming of C++ methods that constitute EOSIO actions into any valid C++ name, as long as you explicitly specify the valid EOSIO action in the corresponding attribute.

The auto-generated dispatcher also enables smart contract developers to split up the logic of their contracts into sub-contracts and use an aggregate pattern to link these actions together in the dispatcher and have greater control in developing easier-to-maintain code.

As part of this new auto-generated dispatcher, all smart-contracts built with this functionality will be default assert if an action is run against it that it has no entry for. The new dispatcher will also assert if the smart-contract receives an onerror notification and the user would have to opt out of this by supplying an explicit notification handler for onerror. If desired, you are still able to write your own dispatcher for the smart contract in which case one will not be auto-generated.

Two new functions are defined for EOSIO smart contract development: pre_dispatch and post_dispatch. These are hooks that the contract writer can define in their smart contract to apply custom validation/logic before any dispatching is done and after any dispatching occurs.

First Class Support for Notification Handling

As mentioned above, notification handling for smart-contracts is now enabled by a new attribute [[eosio::on_notify(<code account>::<action name>]] This marks a method as a notification handler, much like how the [[eosio::action]] attribute is used to mark an action. This new functionality allows smart contract developers to specify what types of notifications a handler handles by giving the code account and name of the action. In addition to this, the code account can be a wild-card (*), which would allow the handler to accept notifications of a particular action from any code accounts. The addition of first class support for notification handling should eliminate the need for smart contract writers to use custom macros or hand write their own dispatchers.

Proper Debugging for “Native” Built Smart-Contracts

Support for source-level debugging for the “native” builds for smart contracts has been added for both Linux and macOS. For more information about the native smart contract API and set of tools, please refer to the native-tester documentation in GitHub.

Partitioning of eosiolib to Better Facilitate Development Best Practices

Historically, the C API for smart contract development has been error-prone to use, but its functions are better served through C++ type-safe alternatives proposed in this release. Going forward, the C API is no longer available to smart-contract developers developing with C++. This may inflict breaking changes for developers that are explicitly using the old C-API. If you still need these, however, you will have to build your smart contract with C and use the C compiler. Note that if you choose this approach, you will lose the ability to use new features, such as auto-generated dispatchers and most of what comes with eosiolib. To ease the transition for smart-contract developers, effort has been made to maintain lexical interfaces with the C intrinsics for their C++ type-safe counterparts. This means that most of the C API intrinsics now have proper C++ type-safe alternatives with no naming changes and take the same number of arguments and use types that lexically “match”. However, some of the intrinsics could not be created this way and may cause breakage of builds. These new partitioned libraries are an opt-in for this release with deprecation warnings for the old includes, so developers have time to update their contracts if they so choose.

New EOSIO.CDT Libraries and Additional Deprecated Tools

Two new libraries have been added to EOSIO.CDT in this release: softfloat and compiler-rt. These can be used with the flag use-rt to produce a binary that doesn’t import the compiler-rt intrinsics. This is useful for generating WebAssembly that is more self-contained. This will be more useful when wasm-ql arrives and future WASM modes are added. (#325)

The eosio-abigen tool has also been deprecated in this release because of the “ABI” linking capabilities of eosio-ld and eosio-cpp. In the future, use eosio-cpp with the — abigen flag. These two should be linked regardless as a best practice because the ABI shouldn’t change unless your contract code is updated. (#377)

For a full list of updates made in this release, please refer to the Summary of Changes in EOSIO.CDT 1.6.0 in detail on Github.

Community Developer Support

In addition to our growing team at Block.one, we would like to send our special thanks to a few other community contributors who have submitted patches for this release. On behalf of the community, thank you for your contributions and commitment to the growth of the EOSIO software:

  • @conr2d
  • @maoueh

Stay Connected

If you are interested in providing feedback and working more closely with our team to improve the EOSIO software for developers, you can send our developer relations team an email at developers@block.one.

You can also keep up to date with future updates by subscribing to our mailing list on the EOSIO Developer Portal. We are excited to be continually improving the usability of the software for EOSIO developers as we continue laying a foundation for the mass adoption of blockchain technology.

Disclaimer

Block.one makes its contribution on a voluntary basis as a member of the EOSIO community and is not responsible for ensuring the overall performance of the software or any related applications. We make no representation, warranty, guarantee or undertaking in respect of the releases described here, the related GitHub release, the EOSIO software or any related documentation, whether expressed or implied, including but not limited to the warranties or merchantability, fitness for a particular purpose and noninfringement. In no event shall we be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or documentation or the use or other dealings in the software or documentation. Any test results or performance figures are indicative and will not reflect performance under all conditions. Any reference to any third party or third-party product, resource or service is not an endorsement or recommendation by Block.one. We are not responsible, and disclaim any and all responsibility and liability, for your use of or reliance on any of these resources. Third-party resources may be updated, changed or terminated at any time, so the information here may be out of date or inaccurate.

--

--