The JS/TS SDK for Muta(a High performance Blockchain framework). Allow you to interact with Muta node's GraphQL service.
npm install graphql@14 @mutadev/muta-sdk
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 multiplegraphql
version conflict error, make sure there was only onegraphql
version in our system. If you are also a library contributor dependent ongraphql
module, you should consider whether to peerDependeies ongraphql
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();
The repo root which organized via monorepo mode, that composed of the following modules
- @mutadev/muta-sdk - All-in-one SDK for Muta framework
- @mutadev/client - Wrapping the GraphQL like RPC
- @mutadev/client-raw - Wrapping the raw Muta GraphQL
- @mutadev/account - Account system for Muta
- @mutadev/service - Wrapping for Muta service
- @mutadev/utils - Commons utils
- @mutadev/wallet - An simple HD wallet implement
- @mutadev/defaults - Defaults constants
- @mutadev/types - The TypeScript definitions
- @mutadev/shared - Shred third-party dependencies
- 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
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