{"id":25130,"library":"cosmwasm-typescript-gen","title":"cosmwasm-typescript-gen","description":"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.","status":"renamed","version":"0.3.9","language":"javascript","source_language":"en","source_url":"https://github.com/pyramation/cosmwasm-typescript-gen","tags":["javascript","typescript"],"install":[{"cmd":"npm install cosmwasm-typescript-gen","lang":"bash","label":"npm"},{"cmd":"yarn add cosmwasm-typescript-gen","lang":"bash","label":"yarn"},{"cmd":"pnpm add cosmwasm-typescript-gen","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"npm install -g cosmwasm-typescript-gen","symbol":"cosmwasm-typescript-gen (CLI)","correct":"npx cosmwasm-typescript-gen generate --schema ./schema --out ./src --name MyContract"},{"note":"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.","wrong":"import { MyContractMessageComposer } from 'cosmwasm-typescript-gen'","symbol":"MessageComposer (codegen output)","correct":"import { MyContractMessageComposer } from './MyContract.react-query'"},{"note":"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.","wrong":"import { useReactQuery } from 'cosmwasm-typescript-gen'","symbol":"ReactQuery (codegen output)","correct":"import { useMyContractQuery } from './MyContract.react-query'"}],"quickstart":{"code":"npx cosmwasm-typescript-gen@0.3.9 generate --schema ./schema --out ./src --name MyContract\n\n# Or for newer projects (recommended):\n# npx @cosmwasm/ts-codegen generate --schema ./schema --out ./src --name MyContract --reactQueryVersion=4","lang":"typescript","description":"Generates TypeScript client code from a CosmWasm contract schema, including types, message builders, and optionally React Query or Recoil hooks."},"warnings":[{"fix":"Migrate to @cosmwasm/ts-codegen (npm install --save-dev @cosmwasm/ts-codegen). Update command usage accordingly.","message":"Renamed to @cosmwasm/ts-codegen: cosmwasm-typescript-gen v0.3.9 is no longer maintained and will not receive updates.","severity":"breaking","affected_versions":"<=0.3.9"},{"fix":"Update any imports referencing MessageComposer to MsgComposer.","message":"MessageComposer renamed to MsgComposer: In @cosmwasm/ts-codegen v0.35, the generated class name changed from <ContractName>MessageComposer to <ContractName>MsgComposer.","severity":"breaking","affected_versions":">=0.35.0"},{"fix":"Pass --reactQueryVersion=3 flag during generation if using React Query v3, or update your React Query to v4.","message":"React Query defaults to v4: ts-codegen now generates React Query v4 hooks by default. Existing v3 code will break.","severity":"breaking","affected_versions":">=0.35.0"},{"fix":"Ensure your Rust contract generates JSON schemas via cosmwasm-schema. Run 'cargo schema' in the contract directory before using this tool.","message":"Requires JSON schema output from Rust contracts: The tool only works if you have run 'cargo schema' in your CosmWasm contract project first.","severity":"gotcha","affected_versions":"all"},{"fix":"npm install @cosmjs/stargate @cosmjs/cosmwasm-stargate","message":"Generated 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.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use npx cosmwasm-typescript-gen generate ... or install locally: npm install --save-dev cosmwasm-typescript-gen@0.3.9","cause":"Global install mismatch or not using npx.","error":"Error: Cannot find module 'cosmwasm-typescript-gen'"},{"fix":"Verify the schema directory exists and contains .json files. Ensure you've run 'cargo schema' in your contract project.","cause":"The --schema path must point to a folder containing valid JSON schema files (usually generated by 'cargo schema').","error":"Schema files not found in directory ./schema"},{"fix":"Install required CosmJS packages: npm install @cosmjs/stargate @cosmjs/cosmwasm-stargate","cause":"Missing or mismatched CosmJS dependencies in your project when using generated message composers.","error":"TypeError: Class extends value undefined is not a constructor or null"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}