Registry / web-framework / cosmwasm-typescript-gen

cosmwasm-typescript-gen

JSON →
library0.3.9jsnpmunverified

A CLI tool and library for generating TypeScript types, message composers, and React query hooks from CosmWasm smart contract JSON schemas. Version 0.3.9 is an older release; the project has been renamed to @cosmwasm/ts-codegen (current v0.35.x) with breaking changes in plugin names and React Query defaults. It provides a code-first approach for Cosmos ecosystem dApp development, generating fully typed client-side code from Rust contract schemas. Compared to manual type definitions, it automates type safety and reduces boilerplate for CosmWasm frontends.

npm install cosmwasm-typescript-gen
INSTALL
IMPORT
SIG · COSMWASM-TYPESCRIP
C
cosmwasm-typescript-gen
web-frameworkjavascriptv0.3.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cosmwasm-typescript-gen (CLI)
✓ npx cosmwasm-typescript-gen generate --schema ./schema --out ./src --name MyContract
✗ npm install -g cosmwasm-typescript-gen
Globally installing is discouraged; use npx for latest or pin to a specific version. The package has been renamed to @cosmwasm/ts-codegen; new projects should use that instead.
MessageComposer (codegen output)
✓ import { MyContractMessageComposer } from './MyContract.react-query'
✗ import { MyContractMessageComposer } from 'cosmwasm-typescript-gen'
The generated files are local to your project, not imported from the npm package. Class name format changed from MessageComposer to MsgComposer in @cosmwasm/ts-codegen v0.35.
ReactQuery (codegen output)
✓ import { useMyContractQuery } from './MyContract.react-query'
✗ import { useReactQuery } from 'cosmwasm-typescript-gen'
React query hooks are generated locally. In @cosmwasm/ts-codegen v0.35+, React Query defaults to v4; for React Query v3 you must pass --reactQueryVersion=3.

Generates TypeScript client code from a CosmWasm contract schema, including types, message builders, and optionally React Query or Recoil hooks.

npx cosmwasm-typescript-gen@0.3.9 generate --schema ./schema --out ./src --name MyContract # Or for newer projects (recommended): # npx @cosmwasm/ts-codegen generate --schema ./schema --out ./src --name MyContract --reactQueryVersion=4
cosmwasm-typescript-gen --version
Debug
Known issues
breakingRenamed to @cosmwasm/ts-codegen: cosmwasm-typescript-gen v0.3.9 is no longer maintained and will not receive updates.
fix
Migrate to @cosmwasm/ts-codegen (npm install --save-dev @cosmwasm/ts-codegen). Update command usage accordingly.
affects: <=0.3.9
breakingMessageComposer renamed to MsgComposer: In @cosmwasm/ts-codegen v0.35, the generated class name changed from <ContractName>MessageComposer to <ContractName>MsgComposer.
fix
Update any imports referencing MessageComposer to MsgComposer.
affects: >=0.35.0
breakingReact Query defaults to v4: ts-codegen now generates React Query v4 hooks by default. Existing v3 code will break.
fix
Pass --reactQueryVersion=3 flag during generation if using React Query v3, or update your React Query to v4.
affects: >=0.35.0
gotchaRequires JSON schema output from Rust contracts: The tool only works if you have run 'cargo schema' in your CosmWasm contract project first.
fix
Ensure your Rust contract generates JSON schemas via cosmwasm-schema. Run 'cargo schema' in the contract directory before using this tool.
affects: all
gotchaGenerated code depends on cosmjs packages: The types use CosmJS types (e.g., Coin, MsgExecuteContract). Your project must have @cosmjs/stargate and @cosmjs/cosmwasm-stargate installed.
fix
npm install @cosmjs/stargate @cosmjs/cosmwasm-stargate
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'cosmwasm-typescript-gen'
Global install mismatch or not using npx.
fix
Use npx cosmwasm-typescript-gen generate ... or install locally: npm install --save-dev cosmwasm-typescript-gen@0.3.9
Schema files not found in directory ./schema
The --schema path must point to a folder containing valid JSON schema files (usually generated by 'cargo schema').
fix
Verify the schema directory exists and contains .json files. Ensure you've run 'cargo schema' in your contract project.
TypeError: Class extends value undefined is not a constructor or null
Missing or mismatched CosmJS dependencies in your project when using generated message composers.
fix
Install required CosmJS packages: npm install @cosmjs/stargate @cosmjs/cosmwasm-stargate
Upgrade
Version history
0.3.9latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
cosmwasm-typescript-gen — npm install cosmwasm-typescript-gen · libregistry