Clarity 4 Proposal: New builtins for vital ecosystem projects

There are several new Clarity features in demand by some vital ecosystem projects, including bridges and marketplaces. This proposal, for Clarity 4, adds three new features that will help enable these applications to be simpler and more secure. I’ve opened a draft SIP with all of the details, but the summary is below.

  1. A new Clarity function to fetch the hash of a contract’s code body. This
    enables on-chain contract code validation, for example allowing contract A to
    validate that contract B follows a specific template and is therefore safe to
    interact with. This is especially useful for enabling bridges and
    marketplaces to safely and trustlessly support a dynamic set of assets.
  2. A new set of Clarity functions to allow a contract to set post-conditions
    to protect its assets.
    These allow a contract to safely call arbitrary
    external contracts (e.g. passed in as traits) while ensuring that if the
    executed code moves assets beyond those specified, the changes will be rolled
    back.
  3. A new Clarity function to convert simple values into string-ascii
    values.
    This function will enable developers to easily convert values like
    bools and principals into their ASCII string representations,
    facilitating the generation of string-based messages for interacting with
    cross-chain protocols.
5 Likes