# @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.

Latest version **0.6.4** (published 2026-05-12) · 0 weekly downloads

## Install

```sh
npm install @defuse-protocol/contract-types
pnpm add @defuse-protocol/contract-types
yarn add @defuse-protocol/contract-types
bun add @defuse-protocol/contract-types
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.6.4 |
| Published | 2026-05-12 |
| First published | 2025-06-17 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 2.6 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | aurorasec, cawabunga_aurora |

## Links

- npm: https://www.npmjs.com/package/@defuse-protocol/contract-types
- Repository: https://github.com/defuse-protocol/sdk-monorepo
- Homepage: https://github.com/defuse-protocol/sdk-monorepo/tree/main/packages/contract-types#readme
- Issues: https://github.com/defuse-protocol/sdk-monorepo/issues
- npm.io page: https://npm.io/package/@defuse-protocol/contract-types

## Dependencies (3)

- [ajv](https://npm.io/package/ajv.md) ^8.17.1
- [ajv-formats](https://npm.io/package/ajv-formats.md) ^3.0.1
- [@standard-schema/spec](https://npm.io/package/@standard-schema/spec.md) ^1.1.0

## Recent versions

- 0.6.4 (latest) — 2026-05-12
- 0.6.3 — 2026-04-13
- 0.6.2 — 2026-02-19
- 0.6.1 — 2026-02-15
- 0.6.0 — 2026-02-03
- 0.5.0 — 2026-01-23
- 0.4.4 — 2026-01-16
- 0.4.3 — 2025-12-02
- 0.4.2 — 2025-11-28
- 0.4.1 — 2025-11-26
- 0.4.0 — 2025-11-26
- 0.3.1 — 2025-11-14
- 0.3.0 — 2025-11-05
- 0.2.0 — 2025-10-31
- 0.1.2 — 2025-10-12
- … 5 more at https://npm.io/package/@defuse-protocol/contract-types/versions

## README

# @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

```bash
npm install @defuse-protocol/contract-types
```

## Standard Schema

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

## Using with Schema Libraries

### class-validator (NestJS)

See [class-validator.test.ts](./src/class-validator.test.ts) for the `ValidateWithSchema` decorator that works with NestJS validation pipes.

### Zod

Two options available in [zod.test.ts](./src/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](./src/valibot.test.ts) for the wrapper function.

### ArkType

See [arktype.test.ts](./src/arktype.test.ts) for the wrapper function.

## Usage

```typescript
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

- [PNPM](https://pnpm.io) (v10.14.0)

### Build

```bash
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:

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

### Development Mode

```bash
pnpm run dev
```

### Lint

```bash
pnpm run lint
```

## License

MIT License © 2025 NEAR Foundation

---
_Source: https://npm.io/package/@defuse-protocol/contract-types · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
