Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

nervosnetwork/muta-sdk-js

Repository files navigation

Muta SDK

The JS/TS SDK for Muta(a High performance Blockchain framework). Allow you to interact with Muta node's GraphQL service.

Quick Start

npm

npm install graphql@14 @mutadev/muta-sdk

yarn

yarn add graphql@14 @mutadev/muta-sdk

Note: The graphql is peerDependent by @mutadev/client-raw. So we need to install it manually. To avoid multiple graphql version conflict error, make sure there was only one graphql version in our system. If you are also a library contributor dependent on graphql module, you should consider whether to peerDependeies on graphql

Usage

const muta = require('@mutadev/muta-sdk');

// muta.setDefaultVariables('MUTA_ENDPOINT', 'http://localhost:8000/graphql');

async function main() {
  const client = new muta.Client();
  const height = await client.getLatestBlockHeight();
  console.log(height);
}

main();

Modules

The repo root which organized via monorepo mode, that composed of the following modules

Links

Development

  • nodejs >= 10
  • yarn

To ensure that the test passes, please enable a muta-example chain before the test

git clone https://github.com/nervosnetwork/muta-sdk-js
cd muta-sdk-js
yarn
yarn test

About Package

All modules are under the packages folder which organized with similar structure

You can also create a muta-sdk-like project based on the template

- package-name
  - src
    - index.ts # export related modules
    - foo.ts # module impl
    - foo.test.ts # unit test for this module
    - foo.e2e.ts # e2e test for this module
  - README.md # some description for this module
  - package.json
  - tsconfig.json