clarinet
clarinet copied to clipboard
Support querying project trait ABIs and implementations
Summary
Currently, there is no convenient way in clarinet to query trait definitions and automatically discover contracts that implement a given trait. This limitation affects developer tooling that needs to reason about trait implementations dynamically.
In practice, this means external tools (like Rendezvous) must manually search for contracts that explicitly declare (impl-trait ...), even though the Clarity VM can determine trait compliance by evaluating contract sources and comparing them to a trait’s ABI.
Proposed Solution
Add two complementary methods to the clarinet-sdk:
getTraitABI(traitIdentifier: string): TraitABI: Retrieves the ABI for a given trait from the project’s contracts (either imported or locally defined).findTraitImplementations(traitABI: TraitABI): ContractId[]: Scans the project for contracts (requirements or project contracts) that implement the given trait, based on ABI compatibility (not only explicit(impl-trait ...)usage).
Additional context
This proposal originated in discussion under #2037.