# sdk-fabric

> sdk of fabric use typescript

Latest version **1.0.10** (published 2021-09-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install sdk-fabric
pnpm add sdk-fabric
yarn add sdk-fabric
bun add sdk-fabric
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.10 |
| Published | 2021-09-08 |
| First published | 2021-07-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 12 |
| Unpacked size | 81.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | lihui |
| Maintainers | lihui7800 |
| Keywords | sdk fabric |

## Links

- npm: https://www.npmjs.com/package/sdk-fabric
- npm.io page: https://npm.io/package/sdk-fabric

## Dependencies (12)

- [yaml](https://npm.io/package/yaml.md) ^1.10.2
- [log4js](https://npm.io/package/log4js.md) ^6.3.0
- [tslint](https://npm.io/package/tslint.md) ^6.1.3
- [asn1.js](https://npm.io/package/asn1.js.md) ^5.4.1
- [ts-node](https://npm.io/package/ts-node.md) ^9.1.1
- [crypto-js](https://npm.io/package/crypto-js.md) ^4.0.0
- [js-sha256](https://npm.io/package/js-sha256.md) ^0.9.0
- [typescript](https://npm.io/package/typescript.md) ^4.2.4
- [@types/node](https://npm.io/package/@types/node.md) ^14.14.41
- [fabric-network](https://npm.io/package/fabric-network.md) ^2.2.5
- [silly-datetime](https://npm.io/package/silly-datetime.md) ^0.1.2
- [fabric-ca-client](https://npm.io/package/fabric-ca-client.md) ^2.2.5

## Recent versions

- 1.0.10 (latest) — 2021-09-08
- 1.0.9 — 2021-09-06
- 1.0.8 — 2021-08-01
- 1.0.7 — 2021-08-01
- 1.0.6 — 2021-07-23
- 1.0.5 — 2021-07-23
- 1.0.4 — 2021-07-20
- 1.0.3 — 2021-07-14
- 1.0.2 — 2021-07-14
- 1.0.1 — 2021-07-08
- 1.0.0 — 2021-07-08

## README

# Hyperledger Fabric sdk utils

sdk of fabric and so on.

#### Supported Hyperledger Fabric versions
> This library has been tested against the v2.0.0 version of Hyperledger

#### demo
``` typescript
import { CreateSDK } from 'sdk-fabric';
import { ISDKBuilder } from 'sdk-fabric/dist/lib/builder';
import { SetLog } from 'sdk-fabric/dist/util/log'
import { Config } from 'sdk-fabric/dist/lib/director';

//配置日志模块
const sdklog=GetLogger('sdk');
SetLog(sdklog);

// 创建sdk
const conf={} as Config
const sdkbuild = await CreateSDK(conf);
if (sdkbuild) {
    return sdkbuild;
}

```

``` typescript

/**
 * 根据高度获取块信息
 * @param {string} channelName
 * @param {number} blockNum
 */
public async QueryBlockByNum(blockNum: number): Promise<Result> {
    const res = {} as Result;
    try {
        const contract = this.sdk.getNetWork().getContract('qscc');
        const resultByte = await contract.evaluateTransaction(
            'GetBlockByNumber',
            conf.sdk.channel,
            String(blockNum),
        );
        const resultJson = await decodeBlock(resultByte);
        const bl = await BlockDecode(resultJson);
        res.data = bl;
        return res;
    } catch (error) {
        logger.error(`Failed to get block ${blockNum} from channel ${conf.sdk.channel} err:${error} `);
        res.error = error;
        if (error.responses.length > 0) {
            res.message = error.responses[0].response.message;
        }
        return res;
    }
}

```

---
_Source: https://npm.io/package/sdk-fabric · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
