3id-blockchain-utils

中文文档
1.3.1发布于 2020/12/16(Apache-2.0 OR MIT)TypeScriptCommonJS近 30 天下载 2079

Blockchain utils for 3ID

此软件包已被标记为弃用

This package has been replaced by @ceramicnetwork/blockchain-utils-linking and @ceramicnetwork/blockchain-utils-validation

原始使用文档
文档目录8 节
  1. Tabel of Contents
  2. Install
  3. Usage
  4. Supported blockchains
  5. Maintainers
  6. Adding support for a blockchain
  7. Test
  8. Licence

3id-blockchain-utils

standard-readme compliant CircleCI npm npm Codecov

This package contains a bunch of utilities that is used by 3ID and 3Box in order to create and verify links from blockchain addresses.

Tabel of Contents

Install

$ npm install --save 3id-blockchain-utils

Usage

Import the package into your project

import { createLink, validateLink, authenticate } from '3id-blockchain-utils'

Use the library to create and verify links:

const did = 'did:3:bafypwg9834gf...'
const proof = await createLink(did, '0x123abc...', ethereumProvider)
console.log(proof)

const verified = await validateLink(proof)
if (verified) {
  console.log('Proof is valid', proof)
} else {
  console.log('Proof is invalid')
}

Use the library for 3ID authenticate:

await authenticate(message, '0x123abc...', ethereumProvider)

Supported blockchains

Below you can see a table which lists supported blockchains and their provider objects.

BlockchainCAIP-2 namespaceSupported providers
Ethereumeip155metamask-like ethereum provider
FilecoinfilFilecoin Wallet Provider

Maintainers

@oed

Adding support for a blockchain

If you want to add support for a new blockchain to 3ID this is the place to do so. This library uses CAIP-10 to represent accounts in a blockchain agnostic way. If the blockchain you want to add isn't already part of the CAIP standards you shold make sure to add it there.

To begin adding support for a given blockchain add a file with the path: src/blockchains/<blockchain-name>.js. This module needs to export three functions:

  • createLink - creates a LinkProof object which associates the specified AccountID with the DID
  • validateLink - validates the given LinkProof
  • authenticate - signs a message and returns some entropy based on the signature. Needs to be deterministic

It also needs to export a constant called namespace. This constant is a string which contains the CAIP-2 chainId namespace.

Please see src/blockchains/ethereum.js for an example of how this is implemented for the eip155 (ethereum) CAIP-2 namespace.

Finally add support for your blockchain in src/index.js. Simply add it to the handlers array.

Test

Test the code by running:

$ npm test

Licence

Apache-2.0 OR MIT

版本与发布记录

3id-blockchain-utils 共发布 19 个版本,首次发布于 2019/11/11;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.3.1latest2020/12/165 年前
1.3.02020/12/165 年前
1.2.02020/12/095 年前
1.1.12020/11/245 年前
1.1.02020/11/185 年前
1.0.02020/08/116 年前

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

关于 3id-blockchain-utils 的常见问题

3id-blockchain-utils 是什么?

Blockchain utils for 3ID注意:该包已被作者标记为弃用——This package has been replaced by @ceramicnetwork/blockchain-utils-linking and @ceramicnetwork/blockchain-utils-validation

如何安装 3id-blockchain-utils?

在项目目录运行 npm install 3id-blockchain-utils,或使用 pnpm add / yarn add / bun add。

3id-blockchain-utils 支持 TypeScript 吗?

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

3id-blockchain-utils 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

3id-blockchain-utils 可以商用吗?

3id-blockchain-utils 使用 (Apache-2.0 OR MIT) 许可。可在 Apache-2.0、MIT 中任选其一遵守。选择 Apache-2.0 时,宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

3id-blockchain-utils 的下载量有多少?

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

3id-blockchain-utils 还在维护吗?

最新版本 1.3.1 发布于 2020/12/16(5 年前);至今共发布 19 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/11/11。作者已将其标记为弃用,新项目建议寻找替代方案。