@cowprotocol/sdk-contracts-ts

中文文档
4.0.1发布于 2026/11/04MITTypeScriptESM + CJS构建来源已验证近 30 天下载 8.5万

TypeScript contract bindings for CoW Protocol SDK

原始使用文档
文档目录7 节
  1. Test coverage
  2. Package Origin
  3. What's included
  4. Installation
  5. Usage
  6. Usage with CoW SDK
  7. Available Contracts

SDK Contracts

Test coverage

StatementsBranchesFunctionsLines
StatementsBranchesFunctionsLines

This package provides TypeScript contract interfaces and utilities for interacting with CoW Protocol smart contracts. It includes type-safe contract wrappers and helper functions for all CoW Protocol contracts.

Package Origin

This package represents a migration and modularization of the TypeScript utilities that were previously located in the contracts repository. The contract interaction logic has been extracted from the main contracts repository and reorganized into this dedicated SDK package to:

  • Improve modularity - Separate smart contract deployment code from client-side interaction utilities
  • Enable independent versioning - Allow contract interfaces to evolve independently from contract deployments
  • Better developer experience - Provide a focused package specifically for TypeScript developers
  • SDK integration - Seamlessly integrate with the broader CoW Protocol SDK ecosystem

What's included

  • Contract Interfaces - TypeScript interfaces for all CoW Protocol smart contracts
  • Contract Utilities - Helper functions for contract interactions
  • Type Safety - Full TypeScript support with proper typing
  • Multi-Chain Support - Contract addresses and interfaces for all supported chains

Installation

npm install @cowprotocol/sdk-contracts-ts

Usage

import { ContractsTs } from '@cowprotocol/sdk-contracts-ts'
import { EthersV6Adapter } from '@cowprotocol/sdk-ethers-v6-adapter'
import { JsonRpcProvider, Wallet } from 'ethers'

// Configure the adapter
const provider = new JsonRpcProvider('YOUR_RPC_URL')
const wallet = new Wallet('YOUR_PRIVATE_KEY', provider)
const adapter = new EthersV6Adapter({ provider, signer: wallet })

// Initialize contracts with adapter
const contracts = new ContractsTs(adapter)

// Use contract interfaces
const settlementContract = contracts.settlement()
const vaultRelayerContract = contracts.vaultRelayer()

Usage with CoW SDK

When using the CoW SDK, contract utilities are automatically available:

import {
  CowSdk,
} from '@cowprotocol/cow-sdk'
import { EthersV6Adapter } from '@cowprotocol/sdk-ethers-v6-adapter'
import { JsonRpcProvider, Wallet } from 'ethers'

// Configure the adapter
const provider = new JsonRpcProvider('YOUR_RPC_URL')
const wallet = new Wallet('YOUR_PRIVATE_KEY', provider)
const adapter = new EthersV6Adapter({ provider, signer: wallet })

// Initialize the unified SDK
const sdk = new CowSdk({
  chainId: SupportedChainId.SEPOLIA,
  adapter,
})

// Access contracts through the SDK
const settlementContract = sdk.contracts.settlement()
const vaultRelayerContract = sdk.contracts.vaultRelayer()

Available Contracts

  • Settlement Contract - Main CoW Protocol settlement contract
  • Vault Relayer - Contract for handling vault interactions
  • Composable CoW - Contract for conditional orders
  • Extensible Fallback Handler - Safe fallback handler for smart contract wallets

Note: This package is primarily designed to provide contract interfaces and is rarely used standalone. Most developers should use @cowprotocol/cow-sdk package which includes all contract utilities with proper adapter configuration.

版本与发布记录

@cowprotocol/sdk-contracts-ts 共发布 79 个版本,首次发布于 2025/08/02;过去 12 个月发布了 54 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
4.0.1latest2026/11/046 天前
4.0.02026/11/037 天前
3.7.62026/10/2615 天前
3.7.52026/10/1328 天前
3.7.42026/10/091 个月前
3.7.32026/10/071 个月前

其他发布通道:next → 2.1.1-beta.0。

关于 @cowprotocol/sdk-contracts-ts 的常见问题

@cowprotocol/sdk-contracts-ts 是什么?

TypeScript contract bindings for CoW Protocol SDK

如何安装 @cowprotocol/sdk-contracts-ts?

在项目目录运行 npm install @cowprotocol/sdk-contracts-ts,或使用 pnpm add / yarn add / bun add。

@cowprotocol/sdk-contracts-ts 支持 TypeScript 吗?

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

@cowprotocol/sdk-contracts-ts 支持 ESM 还是 CommonJS?

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

@cowprotocol/sdk-contracts-ts 可以商用吗?

@cowprotocol/sdk-contracts-ts 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cowprotocol/sdk-contracts-ts 的下载量有多少?

根据 npm 官方下载统计,@cowprotocol/sdk-contracts-ts 在 2026/10/11 – 2026/11/09 这 30 天内被下载 85,265 次,日均约 2,842 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cowprotocol/sdk-contracts-ts 还在维护吗?

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