{"id":48152693,"url":"https://github.com/2wheeh/schemos","last_synced_at":"2026-04-08T21:00:57.655Z","repository":{"id":348657345,"uuid":"1199197390","full_name":"2wheeh/schemos","owner":"2wheeh","description":"Type-safe CosmWasm contract interactions, zero codegen","archived":false,"fork":false,"pushed_at":"2026-04-03T20:41:14.000Z","size":817,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-04T18:34:16.533Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://schemos.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/2wheeh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-02T06:05:28.000Z","updated_at":"2026-04-03T20:41:02.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/2wheeh/schemos","commit_stats":null,"previous_names":["2wheeh/schemos"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/2wheeh/schemos","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2wheeh%2Fschemos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2wheeh%2Fschemos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2wheeh%2Fschemos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2wheeh%2Fschemos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/2wheeh","download_url":"https://codeload.github.com/2wheeh/schemos/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2wheeh%2Fschemos/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31444702,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T15:22:31.103Z","status":"ssl_error","status_checked_at":"2026-04-05T15:22:00.205Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-04T17:13:36.383Z","updated_at":"2026-04-05T18:01:07.867Z","avatar_url":"https://github.com/2wheeh.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# schemos\n\nType-safe CosmWasm contract interactions, zero codegen.\n\nschemos infers TypeScript types from JSON Schema (`cargo schema` output) at compile time and validates messages at runtime — no generated code, no client lock-in.\n\n## Install\n\n```bash\npnpm add schemos\n```\n\n## Quick Start\n\n```typescript\nimport { createTypedContract } from 'schemos'\nimport { cw20 } from 'schemos/schemas'\n\n// Works with any CosmWasm client (cosmjs, telescope SDKs, etc.)\nconst token = createTypedContract(client, 'osmo1...', cw20)\n\n// Execute — message names autocomplete, fields are type-checked\nawait token.execute(\n  senderAddress,\n  'transfer',\n  { recipient: 'osmo1...', amount: '1000' },\n  fee,\n)\n\n// Query — return type inferred from response schema\nconst { balance } = await token.query('balance', { address: 'osmo1...' })\n// balance: string\n```\n\nTypo? Compile error. Missing field? Compile error. Wrong type at runtime? Error thrown before gas is spent.\n\n## How It Works\n\n```\ncargo schema → JSON Schema (as const) → schemos\n                                          ├─ compile time: json-schema-to-ts infers TypeScript types\n                                          └─ runtime: Ajv validates before tx broadcast\n```\n\nSingle source of truth. The same JSON Schema drives both type inference and runtime validation.\n\n## Usage with cosmjs\n\n`SigningCosmWasmClient` works directly — no adapter needed:\n\n```typescript\nimport { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate'\nimport { createTypedContract } from 'schemos'\nimport { cw20 } from 'schemos/schemas'\n\nconst client = await SigningCosmWasmClient.connectWithSigner(rpcEndpoint, signer)\nconst token = createTypedContract(client, contractAddress, cw20)\n\nawait token.execute(sender, 'transfer', { recipient: '...', amount: '1000' }, 'auto')\nconst { balance } = await token.query('balance', { address: '...' })\n```\n\nQuery-only (no signing):\n\n```typescript\nimport { CosmWasmClient } from '@cosmjs/cosmwasm-stargate'\n\nconst client = await CosmWasmClient.connect(rpcEndpoint)\nconst token = createTypedContract(client, contractAddress, {\n  query: cw20.query,\n  responses: cw20.responses,\n})\n// token.query() available with typed responses, token.execute() does not exist\nconst { balance } = await token.query('balance', { address: '...' })\n// balance: string — inferred from response schema\n```\n\n## Usage with telescope SDKs (xplajs / osmojs / neutronjs)\n\nTelescope-generated SDKs use protobuf RPCs instead of cosmjs's JSON API. schemos provides a generic adapter via `schemos/telescope`:\n\n```typescript\nimport { createExecuteAdapter } from 'schemos/telescope'\nimport { createTypedContract } from 'schemos'\nimport { cw20 } from 'schemos/schemas'\n\n// Each chain's telescope package provides MsgExecuteContract\nimport { MsgExecuteContract } from '@xpla/xplajs/cosmwasm/wasm/v1/tx'\n// or: import { MsgExecuteContract } from 'osmojs/cosmwasm/wasm/v1/tx'\n\n// Query: telescope RPC function\nimport { createGetSmartContractState } from '@xpla/xplajs/cosmwasm/wasm/v1/query.rpc.func'\nconst smartContractState = createGetSmartContractState(rpcEndpoint)\n\nconst adapter = createExecuteAdapter(\n  smartContractState,\n  (sender, msgs, fee, memo) =\u003e signingClient.signAndBroadcast(sender, msgs, fee, memo),\n  (p) =\u003e MsgExecuteContract.encode(MsgExecuteContract.fromPartial({ ...p, funds: [...p.funds] })).finish(),\n)\n\nconst token = createTypedContract(adapter, contractAddress, cw20)\nawait token.execute(sender, 'transfer', { recipient: '...', amount: '1000' }, 'auto')\n```\n\n\u003e **Why callbacks?** CosmWasm is an opt-in module — `MsgExecuteContract` lives in each chain's telescope package (`@xpla/xplajs`, `osmojs`, `neutronjs`), not in `@interchainjs/cosmos-types`. The adapter accepts callbacks so schemos doesn't depend on any specific chain SDK.\n\nFor React integration with interchain-kit or cosmos-kit, see [docs/wallet-integration.md](./docs/wallet-integration.md).\n\n## Custom Contracts\n\nRun `cargo schema` on your contract, import the JSON as `as const`:\n\n```typescript\nimport { createTypedContract } from 'schemos'\n\n// Your contract's schema output\nconst myExecuteSchema = { /* cargo schema JSON */ } as const\nconst myQuerySchema = { /* cargo schema JSON */ } as const\n\nconst contract = createTypedContract(client, contractAddress, {\n  execute: myExecuteSchema,\n  query: myQuerySchema,\n})\n\n// Full autocomplete + type checking for your custom contract messages\nawait contract.execute(sender, 'your_msg', { /* typed fields */ }, 'auto')\n```\n\nWith response typing:\n\n```typescript\nconst myResponseSchemas = {\n  get_state: { /* response_to_get_state.json */ } as const,\n  get_config: { /* response_to_get_config.json */ } as const,\n}\n\nconst contract = createTypedContract(client, contractAddress, {\n  execute: myExecuteSchema,\n  query: myQuerySchema,\n  responses: myResponseSchemas,\n})\n\n// Return type inferred from response schema\nconst state = await contract.query('get_state', {})\n```\n\n## Bundled Schemas\n\n```typescript\nimport { cw20, cw721 } from 'schemos/schemas'\n\n// cw20: transfer, burn, send, mint, allowances, etc.\nconst token = createTypedContract(client, addr, cw20)\n\n// cw721: transfer_nft, send_nft, approve, mint, burn, etc.\nconst nft = createTypedContract(client, addr, cw721)\n```\n\nIndividual schema imports also available:\n\n```typescript\nimport { cw20ExecuteSchema, cw20QuerySchema, cw20ResponseSchemas } from 'schemos/schemas'\n```\n\n## Comparison\n\n|                    | @cosmwasm/ts-codegen | Manual typing   | **schemos**              |\n|--------------------|----------------------|-----------------|--------------------------|\n| Approach           | Full codegen         | Hand-written    | JSON Schema → inference  |\n| Generated code     | Hundreds of lines    | 0               | 0                        |\n| Schema change      | Re-run + commit      | Manual update   | Replace JSON             |\n| Compile-time types | Yes                  | If maintained   | Yes                      |\n| Runtime validation | No                   | No              | Yes (Ajv)                |\n| Client dependency  | cosmjs only          | Any             | Any                      |\n\n## API\n\n### `createTypedContract(client, contractAddress, schemas)`\n\nCreates a typed contract instance.\n\n- **client**: Any object matching `CosmWasmQueryClient` or `CosmWasmExecuteClient`\n- **contractAddress**: Contract bech32 address\n- **schemas**: `{ execute?, query, responses? }` — raw `cargo schema` JSON as `as const`\n\nReturns `TypedContract` (with execute) or `TypedQueryContract` (query-only).\n\n### `schemos/telescope`\n\n- **`createQueryAdapter(smartContractState)`** — Wraps a telescope RPC query function into `CosmWasmQueryClient`\n- **`createExecuteAdapter(smartContractState, signAndBroadcast, encodeMsgExecuteContract)`** — Full adapter for telescope SDKs\n\n### `schemos/schemas`\n\n- **`cw20`** — `{ execute, query, responses }` for CW20 fungible tokens\n- **`cw721`** — `{ execute, query, responses }` for CW721 NFTs\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2wheeh%2Fschemos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F2wheeh%2Fschemos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2wheeh%2Fschemos/lists"}