Skip to content

Stacks Kit: one typed client library for Stacks #1875

Description

@hugo-stacks

Context

The JS/TS surface for building on Stacks is fragmented: a trivial app touches 5+ npm packages, three doc sites, and three different calling conventions for the same contract function (simnet, backend, wallet). Nothing is type-safe. Contracts, functions, and args are unchecked strings, and results decode to any. The community keeps routing around our primitives with abstraction layers (Clarigen, clarity-abitype, secondlayer, Scaffold Stacks), which is a strong signal. This also matters for agents: LLMs reach for viem on EVM because it's one coherent, typed surface; our fragmented default is what gets baked into every AI-assisted Stacks app.

Direction

Build a viem-like unified client that consolidates Stacks.js and the API client libraries behind one interface: one way to read, call, and broadcast, from simnet to mainnet. Add end-to-end type safety via Clarity to TypeScript type inference, generated by Clarinet and consumed by the client. Phase 1 is type inference (highest value, smallest scope); package unification follows. Sizing comes out of a spike, not before.

Tasks

  • Define TS type layer on top of Stacks contract interface
  • Implement the type layer generation in Clarinet
    • based on the Clarinet.toml
    • for any arbitrary contract via CLI
  • Typed contract client in Stacks.js based on the type layer
  • Stacks.js can be used to interact with smart contract in Clarinet simnet

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions