Skip to content

Conversation

@obycode
Copy link
Contributor

@obycode obycode commented Aug 14, 2025

The Clarity smart contract language powers decentralized applications across a
wide range of domains. Over years of real-world use, developers have encountered
several pain points when interacting with other, sometimes untrusted, contracts.
Securely calling unknown contracts unlocks powerful use cases, but demands
careful safeguards.

This SIP addresses common feedback and requests from builders in the ecosystem.
It proposes new Clarity features to make it easier for developers to write
secure and composable smart contracts. Specifically, it proposes:

  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.

Note

Additional feature added 👇

  1. A new Clarity keyword to get the timestamp of the current block. This
    keyword will allow developers to easily access the timestamp of the block
    currently being processed, enabling time-based logic and features in their
    smart contracts. This is especially important for DeFi applications.

Without a `with-stacking`, the body may not stack the STX of the
`asset-owner`.
Allowances are now passed in as an argument to the expression, similar
to the way `let` works.
@obycode obycode marked this pull request as ready for review August 18, 2025 15:26
Using `u0` for an error code might be confusing, so start at `u1`.
@Rapha-btc
Copy link

Thank you for adding secp256r1 support to SIP-033. This allows Stacks developers to build applications with native passkey integration, unlocking use cases like 2FA for VCs in multisig setups, embedded mints on X with Touch ID purchases, and instant wallet creation with Face ID in seconds. All secured by the user's device secure enclave without third parties.

@wileyj
Copy link
Contributor

wileyj commented Oct 8, 2025

@obycode now that sip number is assigned, can you rename the folder to sip-033 from sip-clarity4 ?

@obycode
Copy link
Contributor Author

obycode commented Oct 8, 2025

@obycode now that sip number is assigned, can you rename the folder to sip-033 from sip-clarity4 ?

Done ✅

@whoabuddy whoabuddy changed the title Clarity 4: high-demand new builtins SIP-033: Clarity 4: high-demand new builtins Oct 16, 2025
@Rapha-btc
Copy link

I'm looking for examples of contract-hash? usage to verify DEX templates before they can self-register for token transfers. This would enforce royalties when users sell tokens to DEX contracts by creating an auto-allowlist of compliant exchanges that implement a required royalty-collecting function. My first implementation is at https://github.com/Rapha-btc/pizza-square/blob/main/contracts/pizza-faktory.clar copy @obycode

Copy link
Contributor

@314159265359879 314159265359879 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great to me. I am hereby signing-off on SIP033.

I see one open comment, I would like to see addressed but I consider that non-blocking for this editor sign-off.

@mphizi
Copy link

mphizi commented Oct 24, 2025

Hi @obycode, did the proposal for type-aliases (clarity-lang/reference#6) especially for tuples and list definitions get into this SIP or SIP-034?

I think this would really great ergonomic improvement. Thanks for all the great work taking place in the ecosystem!

@obycode
Copy link
Contributor Author

obycode commented Oct 24, 2025

Hi @obycode, did the proposal for type-aliases (clarity-lang/reference#6) especially for tuples and list definitions get into this SIP or SIP-034?

Hi @mphizi. Thanks for the input. No, this set of changes described here is all that is included in Clarity 4, but that one is definitely still on the list to include in a future version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.