@colony/colony-js

中文文档
8.1.0发布于 2025/01/30GPL-3.0-onlyTypeScriptESM + CJS近 30 天下载 3798

📜 The Colony TypeScript reference implementation

原始使用文档
文档目录4 节
  1. Documentation
  2. Get Started
  3. Too complicated? Need more guidance?
  4. License

📜 The Colony TypeScript reference implementation

@colony/colony-js

colonyJS is a JavaScript library with a simple and predictable interface for application-layer integrations with the colonyNetwork smart contracts. To learn more about Colony, you can visit colony.io or read the White Paper.

Documentation

📑 Click here for docs!

You should check out the getColonyNetworkClient function in ColonyNetworkClient and the docs for the extended colony contracts clients/Colony/ColonyClientVX.

Get Started

import { providers, utils, Wallet } from 'ethers';
import { getColonyNetworkClient, ColonRpcEndpoint, Id, Network, Tokens } from '@colony/colony-js';

const { formatEther } = utils;

const provider = new providers.JsonRpcProvider(ColonyRpcEndpoint.ArbitrumOne);

const start = async () => {
  // Get a wallet instance
  const wallet = new Wallet(
    // This is a random private key (don't use this one for anything else and _definitely_ do not send valuables to the corresponding address)
    '0x0355596cdb5e5242ad082c4fe3f8bbe48c9dba843fe1f99dd8272f487e70efae',
    provider,
  );

  // Check out the logs to see the wallet address
  console.log('Wallet Address:', wallet.address);

  // Get a network client instance for ArbitrumOne Chain
  const networkClient = getColonyNetworkClient(
    Network.ArbitrumOne,
    wallet,
  );

  // Let's connect to the Meta Colony
  const metaColonyClient = await networkClient.getMetaColonyClient()
  // And check out it's CLNY funding
  const funding = await metaColonyClient.getFundingPotBalance(Id.RootPot, Tokens.ArbitrumOne.CLNY);
  // We can also see its address
  const { address } = metaColonyClient;
  console.info(`${formatEther(funding)} CLNY in root domain of MetaColony with address: ${address}`);
};

start();

Too complicated? Need more guidance?

Try Colony SDK.

License

GPL-3.0

版本与发布记录

@colony/colony-js 共发布 210 个版本,首次发布于 2020/04/13;过去 12 个月发布了 0 个版本。

版本发布日期距今
8.1.0latest2025/01/301.8 年前
8.0.02025/01/091.8 年前
8.0.0-next.1next2024/12/051.9 年前
8.0.0-next.02024/10/302 年前
7.2.02024/09/252 年前
0.0.0-snapshot-85097e5-20240902145835snapshot2024/09/022 年前

其他发布通道:experimental → 4.2.0-experimental.6,beta → 6.2.0-beta.1,rc → 4.2.2-rc.4,next-6 → 6.5.0-next.3,snapshot → 0.0.0-snapshot-85097e5-20240902145835,next → 8.0.0-next.1。

关于 @colony/colony-js 的常见问题

@colony/colony-js 是什么?

📜 The Colony TypeScript reference implementation

如何安装 @colony/colony-js?

在项目目录运行 npm install @colony/colony-js,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:ethers(^5.1.3)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@colony/colony-js 支持 TypeScript 吗?

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

@colony/colony-js 支持 ESM 还是 CommonJS?

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

@colony/colony-js 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^18 || ^20 || ^22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@colony/colony-js 可以商用吗?

@colony/colony-js 使用 GPL-3.0-only 许可。强 Copyleft:分发包含该代码的软件时,整个作品需以 GPL-3.0 兼容许可开源,并附带专利与反锁定条款。仅内部使用不触发此义务。以上为概括,不构成法律意见,请以许可原文为准。

@colony/colony-js 的下载量有多少?

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

@colony/colony-js 还在维护吗?

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