@defuse-protocol/contract-types

中文文档
0.6.4发布于 2026/05/13TypeScriptESM + CJS近 30 天下载 4万

This package provides TypeScript type definitions for Defuse Protocol contracts. It contains automatically generated TypeScript interfaces derived from the Defuse Protocol contract ABI.

原始使用文档
文档目录16 节
  1. Installation
  2. Standard Schema
  3. Using with Schema Libraries
  4. class-validator (NestJS)
  5. Zod
  6. Valibot
  7. ArkType
  8. Usage
  9. Available Types
  10. Development
  11. Prerequisites
  12. Build
  13. Generating Types
  14. Development Mode
  15. Lint
  16. License

@defuse-protocol/contract-types

This package provides TypeScript type definitions for Defuse Protocol contracts. It contains automatically generated TypeScript interfaces derived from the Defuse Protocol contract ABI.

Installation

npm install @defuse-protocol/contract-types

Standard Schema

Validators are Standard Schema compliant and work with any library that accepts the spec (TanStack Form, Hono, tRPC, etc.). See standard-schema.test.ts for usage examples.

Using with Schema Libraries

class-validator (NestJS)

See class-validator.test.ts for the ValidateWithSchema decorator that works with NestJS validation pipes.

Zod

Two options available in zod.test.ts:

  • z.fromJSONSchema() - validates raw structure only, no JSON string parsing
  • toZodSchema() wrapper - validates and parses inner JSON strings

Valibot

See valibot.test.ts for the wrapper function.

ArkType

See arktype.test.ts for the wrapper function.

Usage

import { Intent } from '@defuse-protocol/contract-types';

// Use the generated types in your application
const transferIntent: Intent = {
  intent: "transfer",
  receiver_id: "receiver.near",
  tokens: {
    "token.near": "1000000000000000000000000"
  }
};

Available Types

This package exports the following TypeScript types:

  • Intent - Types for various intent actions (transfer, add_public_key, remove_public_key, etc.)
  • And other contract-related types derived from the Defuse Protocol ABI

Development

Prerequisites

Build

pnpm run build

Generating Types

The types are automatically generated from the Defuse Protocol contract ABI using the script at scripts/gen-defuse-types.ts. This script extracts the type definitions from the contract ABI and converts them to TypeScript interfaces.

To regenerate the types:

# Run the type generation script
cd packages/contract-types
pnpm run gen-defuse-types

Development Mode

pnpm run dev

Lint

pnpm run lint

License

MIT License © 2025 NEAR Foundation

版本与发布记录

@defuse-protocol/contract-types 共发布 20 个版本,首次发布于 2025/06/17;过去 12 个月发布了 12 个版本。

版本发布日期距今
0.6.4latest2026/05/135 个月前
0.6.32026/04/136 个月前
0.6.22026/02/198 个月前
0.6.12026/02/168 个月前
0.6.02026/02/049 个月前
0.5.02026/01/239 个月前

关于 @defuse-protocol/contract-types 的常见问题

@defuse-protocol/contract-types 是什么?

This package provides TypeScript type definitions for Defuse Protocol contracts. It contains automatically generated TypeScript interfaces derived from the Defuse Protocol contract ABI.

如何安装 @defuse-protocol/contract-types?

在项目目录运行 npm install @defuse-protocol/contract-types,或使用 pnpm add / yarn add / bun add。

@defuse-protocol/contract-types 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@defuse-protocol/contract-types 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@defuse-protocol/contract-types 可以商用吗?

@defuse-protocol/contract-types 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@defuse-protocol/contract-types 的下载量有多少?

根据 npm 官方下载统计,@defuse-protocol/contract-types 在 2026/10/12 – 2026/11/10 这 30 天内被下载 40,149 次,日均约 1,338 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@defuse-protocol/contract-types 还在维护吗?

最新版本 0.6.4 发布于 2026/05/13(5 个月前);至今共发布 20 个版本,其中过去 12 个月发布了 12 个;首次发布于 2025/06/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。