muta-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.10.1 • Public • Published

Muta SDK(WIP)

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

Quick Start

npm install muta-sdk

Example

The following code will shows

  1. How to interact with #[read] service
  2. How to sign a transaction
  3. How to sendTransaction
async function main() {
  // get metadata from the chain
  const metadataResponse = await client.queryServiceDyn({
    method: 'get_metadata',
    payload: '',
    serviceName: 'metadata',
  });

  console.log(metadataResponse);

  // Accounts with permission to modify metadata
  const admin = Muta.accountFromPrivateKey('0x...');

  // Preparing transaction
  const tx = await client.composeTransaction({
    method: 'update_metadata',
    payload: {
      // ...
    },
    serviceName: 'metadata',
  });
  const signedTx = admin.signTransaction(tx);
  const txHash = await client.sendTransaction(signedTx);
  const receipt = await client.getReceipt(txHash);

  console.log(receipt);
}

Create Service Binding

Before we create our custom binding, learn about what is a service in Muta. We'll still use AssetService as an example.

Links

Development

  • nodejs >= 10
  • typescript >= 3.7
  • yarn
git clone https://github.com/nervosnetwork/muta-sdk-js
cd muta-sdk-js
yarn
yarn start

Readme

Keywords

none

Package Sidebar

Install

npm i muta-sdk

Weekly Downloads

1

Version

0.10.1

License

MIT

Unpacked Size

299 kB

Total Files

161

Last publish

Collaborators

  • homura