# Unielon Telegram SDK

## Install

```bash
npm install @unielon/unielon-tg-sdk
```

## Usage

```javascript
import { UnielonWallet } from "@unielon/unielon-tg-sdk";
const { unielon } = new UnielonWallet({ ...options });
```

### init options configuration

UnielonWallet instance `options` configuration

| name                  | description                               | type      | default                          |
| --------------------- | ----------------------------------------- | --------- | -------------------------------- |
| `connect_direct_link` | wallet Telegram bot app url               | `string`  | `https://t.me/unielonbot/wallet` |
| `injected`            | Has it been injected into the web window? | `boolean` | `false`                          |
| `request_timeout`     | timeout                                   | `number`  | `1000`                           |
| `metaData`            | client info                               | `Object`  | -                                |

`metaData` configuration

| name          | description     | type     | default |
| ------------- | --------------- | -------- | ------- |
| `hostname`    | hostname        | `string` | -       |
| `icon`        | clinet icon     | `string` | -       |
| `name`        | client name     | `string` | -       |
| `url`         | url,you clicent | `string` | -       |
| `description` | description     | `string` | -       |
| `direct_link` | direct link     | `string` | -       |

## Unielon wallet chain API

Code snippet for dogecoin chain request:

```javascript
try {
  const result = await unielon.requestAccounts();
  // result is {code,message,data: ['Dt92u***29dc',...]}
  return result;
} catch (error) {
  // This error code indicates that the chain has not been added to Unielon Wallet.
}
```

### Dogecoin chain request Api

| method            | description                                                          | params | response |
| ----------------- | -------------------------------------------------------------------- | ------ | -------- |
| `requestAccounts` | connect dogecoin wallet                                              | -      | -        |
| `sendDogecoin`    | Send Dogecoin transaction request,inscription&deploy&mint Drc20 tick | -      | -        |
| `sendTrade`       | Send Dogecoin trade request                                          | -      | -        |
| `sendBox`         | Send box transaction request                                         | -      | -        |
| `createLp`        | Create liquidity pool for trading pair                               | -      | -        |
| `createSwap`      | Send swap transaction                                                | -      | -        |
| `sendBox`         | Box inscription, deployment and minting                              | --     | -        |
| `getBalance`      | get dogecoin chain balances                                          | --     | -        |
| `getNetwork`      | get dogecoin chain network                                           | --     | -        |
| `getAccounts`     | get dogecoin accounts                                                | --     | -        |
| `signMessage`     | sign a message with the connected wallet.                            | --     | -        |
| `sendNft`         | get dogecoin address                                                 | --     | -        |
