The JS/TS SDK for Muta(a High performance Blockchain framework). Allow you interact with Muta node's GraphQL service.
npm install muta-sdk
The following code will shows
- How to interact with
#[read]
service - How to sign a transaction
- 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);
}
Before we create our custom binding, learn about what is a service in Muta. We'll still use AssetService as an example.
- nodejs >= 10
- typescript >= 3.7
- yarn
git clone https://github.com/nervosnetwork/muta-sdk-js
cd muta-sdk-js
yarn
yarn start