sarvalabs / js-moi-sdk

JavaScript library to interact with MOI Protocol via RPC API
https://js-moi-sdk.docs.moi.technology/
Apache License 2.0
24 stars 2 forks source link
blockchain javascript moi sdk web3

image

docs npm version license

latest tag issue count pulls count test status

js-moi-sdk

js-moi-sdk is a Javascript/Typescript implementation of a feature-rich library designed to seamlessly interact with the MOI Protocol and its extensive ecosystem. It provides a convenient interface for interacting with the MOI protocol, allowing developers to create, sign, and send interactions, retrieve account balances, access interaction history, and more.

Installation

Install the latest release using the following command.

npm install js-moi-sdk

Usage

    import { JsonRpcProvider } from "js-moi-sdk";

    (async() => {
        const provider = new JsonRpcProvider("http://localhost:1600");
        const address  = "0xf350520ebca8c09efa19f2ed13012ceb70b2e710241748f4ac11bd4a9b43949b";
        const tesseract = await provider.getTesseract(address, true);
        console.log(tesseract);
    })()

    // Output:
    /*
        {
            "header": {
                "address": "0xf350520ebca8c09efa19f2ed13012ceb70b2e710241748f4ac11bd4a9b43949b",
                "prev_hash": "0x034e75e7d8b2910004e70d6d45157166e87fb1d47485248edf8919108179307e",
                "height": "0x1",
                "fuel_used": "0x64",
                "fuel_limit": "0x3e8",
                ...
            },
            "body": {
                "state_hash": "0x82543da922babd1c32b4856edd44a4bf5881edc3714cfe90b6d1576e00164aee",
                "context_hash": "0xa1058908a4db1594632be49790b24211cd4920a0f27b3d2b876808f910b3e320",
                "interaction_hash": "0x8aab5bc0817393d2ea163482c13ccc0f8f3e01cef0c889b8b3cffb51e4d76894",
                "receipt_hash": "0x3e35a1f481df15da518ef6821f7b6f340f74f4f9c3f3eb30b15944ffea144f75",
                ...
            },
            "ixns": [
                {
                    "type": 3,
                    "nonce": "0x0",
                    "sender": "0xf350520ebca8c09efa19f2ed13012ceb70b2e710241748f4ac11bd4a9b43949b",
                    "receiver": "0x0000000000000000000000000000000000000000000000000000000000000000",
                    "payer": "0x0000000000000000000000000000000000000000000000000000000000000000",
                    ...
                    "hash": "0x7750a0f1c848e05f1e52204e464af0d9d2f06470117e9187bb3643216c4c4ee9"
                }
            ],
            "seal": "0x0460afdac7733765afa6410e58ebe0d69d484dfe021fba989438c51c69c078d6677446f179176681f005c0d755979bf81c090e02fdf8544bc618463e86c2778b7764b90c813f58a5965a47c5572bcf5784743e4c6c425e4bfa0f18b043e9aff21183",
            "hash": "0xd343a7336df38590b47e5b20cb65940f463c358a08cded7af7cd6cde63a5575f"
        }
    */

Sub Packages

The js-moi-sdk package consists of several sub-packages, each offering independent functionality that can be utilized separately to enhance your development experience.

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as below, without any additional terms or conditions.

License

© 2023 Sarva Labs Inc. & MOI Protocol Developers.

This project is licensed under either of

at your option.

The SPDX license identifier for this project is MIT OR Apache-2.0.