# Mantrachain SDK [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Pre-requisites

- [Node.js](https://nodejs.org/en/) >= 18.12.0
- [Yarn](https://yarnpkg.com/) >= 1.22.18
- [Ignite](https://github.com/ignite/cli) = 0.27.1

## Installation

Using npm:

```shell
npm i --save @mantrachain/sdk
```

## Development

Clone the source:

```shell
git clone https://github.com/MANTRA-Finance/mantrachain-sdk.git
```

Change directory:

```shell
cd mantrachain-sdk
```

Install the dependencies:

```shell
npm i
```

Parse the proto files:

```shell
./scripts/sdk.gen.sh {branch}
```

- `{branch}`: [mantrachain](https://github.com/MANTRA-Finance/mantrachain)'s branch name of the proto files <i>(default: develop)</i>

Update the generated files:

```shell
./scripts/update-signer.sh
```

Build:

```shell
npm run build
```

## Usage

```javascript
import { Client, utils } from "@mantrachain/sdk";
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";

(async () => {
  const mnemonic = "..."; // MNEMONIC
  const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, {
    prefix: "mantra",
  });

  const creator = (await wallet.getAccounts())[0].address;

  const client = new Client(
    {
      apiURL: "http://127.0.0.1:1317",
      rpcURL: "http://127.0.0.1:26657",
      prefix: "mantra",
    },
    wallet
  );
})();
```

## Modules Docs

- [x/guard](./docs/modules/guard.md)
- [x/coinfactory](./docs/modules/coinfactory.md)
- [x/token](./docs/modules/token.md)
- [x/liquidity](./docs/modules/liquidity.md)
- [x/lpfarm](./docs/modules/lpfarm.md)

### For pull requests

- Use [semantic commit messages](https://www.conventionalcommits.org/)
