@cowprotocol/sdk-cow-shed

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

CowProtocol Cow Shed package

原始使用文档
文档目录3 节
  1. Test coverage
  2. Usage
  3. Using via Cow SDK

Cow Shed SDK

Test coverage

StatementsBranchesFunctionsLines
StatementsBranchesFunctionsLines

The Cow Shed SDK is a TypeScript library that provides a set of functions to interact with the Cow Shed contract.

In essence, CoW Shed acts as a user owned smart contract (1/1 multisig if you will) that can execute multiple calls on behalf of the user (once the user has pre-authorized the calls).

Usage

import { ethers } from 'ethers'
import { CowShedSdk, ICoWShedCall, SupportedChainId } from '@cowprotocol/cow-shed'
import { EthersV6Adapter } from '@cowprotocol/sdk-ethers-v6-adapter'
import { JsonRpcProvider, Wallet } from 'ethers'

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

const cowShedSdk = new CowShedSdk(adapter) // adapter is optional - will use global adapter if not provided

// Get the cow-shed account for any given chainId and owner's address
const cowShedAccount = cowShedSdk.getCowShedAccount(1, '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045')

// Prepare the calls you want to execute using the cow-shed account
const calls: ICoWShedCall[] = [
  {
    target: '<contract-address-1>',
    callData: 'call-data-1',
    value: 0n,
    isDelegateCall: true,
    allowFailure: false,
  },
  {
    target: '<contract-address-2>',
    callData: '<call-data-2>',
    value: 0n,
    isDelegateCall: true,
    allowFailure: false,
  },
]

// Sign the calls
const preAuthorizedCall = await cowShedSdk.signCalls({
  chainId: SupportedChainId.MAINNET,
  calls,
  signer: '<privateKeyOrEthersSigner>', // signer is optional - will use global adapter's signer if not provided
})

// Get the details of the pre-authorized call you need to send
const { signedMulticall, gasLimit } = preAuthorizedCall
const { to, data, value } = signedMulticall

// Execute the transaction using any wallet. The calldata has been pre-authed, so you don't need any
// special permissions to send this transaction
let anotherWallet = new ethers.Wallet('<another-private-key>')
const tx = await anotherWallet.sendTransaction({
  to,
  data,
  value,
  gasLimit,
})

Use encodeExecuteOwnHooks to encode a factory executeOwnHooks call.

Using via Cow SDK

You can also import CowShedSdk directly from the main SDK:

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

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

const cowShedSdk = new CowShedSdk(adapter) // adapter is optional - will use global adapter if not provided
// ... rest of the usage remains the same

版本与发布记录

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

版本发布日期距今
0.6.8latest2026/11/046 天前
0.6.72026/11/037 天前
0.6.62026/10/2615 天前
0.6.52026/10/1328 天前
0.6.42026/10/091 个月前
0.6.32026/10/071 个月前

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

关于 @cowprotocol/sdk-cow-shed 的常见问题

@cowprotocol/sdk-cow-shed 是什么?

CowProtocol Cow Shed package

如何安装 @cowprotocol/sdk-cow-shed?

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

@cowprotocol/sdk-cow-shed 支持 TypeScript 吗?

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

@cowprotocol/sdk-cow-shed 支持 ESM 还是 CommonJS?

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

@cowprotocol/sdk-cow-shed 可以商用吗?

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

@cowprotocol/sdk-cow-shed 的下载量有多少?

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

@cowprotocol/sdk-cow-shed 还在维护吗?

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