# mempools-sdk

> *** This SDK was created to run on frontend application. If you want to use it in a nodejs app you must install: https://www.npmjs.com/package/mempools-server-sdk ***

Latest version **1.0.5** (published 2023-08-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install mempools-sdk
pnpm add mempools-sdk
yarn add mempools-sdk
bun add mempools-sdk
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2023-08-25 |
| First published | 2023-08-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 971.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | mempools |

## Links

- npm: https://www.npmjs.com/package/mempools-sdk
- npm.io page: https://npm.io/package/mempools-sdk

## Dependencies (3)

- [grpc-web](https://npm.io/package/grpc-web.md) ^1.4.2
- [typescript](https://npm.io/package/typescript.md) ^5.1.6
- [google-protobuf](https://npm.io/package/google-protobuf.md) ^3.21.2

## Recent versions

- 1.0.5 (latest) — 2023-08-25
- 1.0.4 — 2023-08-24
- 1.0.3 — 2023-08-21
- 1.0.2 — 2023-08-20
- 1.0.1 — 2023-08-17
- 1.0.0 — 2023-08-17

## README

# Mempools Client SDK
*** 
This SDK was created to run on frontend application. If you want to use it in a nodejs app you must install: https://www.npmjs.com/package/mempools-server-sdk
***

## **Introduction**

The **`mempools-sdk`** is a software development kit (SDK) designed to provide an easy-to-use interface for interacting with the Mempools API. It allows developers to integrate monitoring and alerting functionality related to Cosmos and EVM blockchains transactions and smart contract events into their applications.

## **Installation**

You can install the **`mempools-sdk`** package using npm:

```bash
npm install mempools-sdk
```

## **Usage**

To utilize the functionalities provided by the **`mempools-sdk`**, you can import the necessary modules and classes as shown below:

```jsx
import { mempools } from "mempools-sdk";
```

## **Function Return Types**

The Cosmos SDK methods will return one of two types: **`ErrorType`** or **`SuccessType`**.

### **`ErrorType`**

An **`ErrorType`** is returned if the operation encounters an error. It consists of the following properties:

- **`status`** (string): Describes the status of the operation, which will be **`"FAIL"`** in case of an error.
- **`data`** (any): Contains information about the error, providing details about what went wrong.

### **`SuccessType`**

A **`SuccessType`** is returned if the operation is successful. It consists of the following properties:

- **`status`** (string): Describes the status of the operation, which will be **`"SUCCESS"`** in case of success.
- **`data`** (any): Contains the data resulting from the successful operation, providing information or the result of the operation.

These return types allow you to easily determine the outcome of each operation performed using the Cosmos SDK.

## Common methods

### Config

It is recommended to call the **`config`** method at the top level of your application, such as in your main entry file, before any other interactions with the Mempools SDK. By setting up the configuration at the beginning of your application, you ensure that the necessary credentials and API endpoint are available for all subsequent SDK operations.

## **Usage**

```jsx
mempools.config({
  clientToken: process.env.CLIENT_TOKEN,
  apiEndpoint: process.env.API_URL,
});
```

After calling the **`config`** method with the appropriate configuration options, you can proceed to use the Mempools SDK's methods to manage alerts and interact with the Mempools API. The configured credentials and API endpoint will be automatically used by the SDK for authentication and communication.

## Alert Methods

### Get Alerts

****`getAlerts({clientId: string, chainId: string, page?: number}): Promise<SuccessType | ErrorType>`****

Get all alerts from a client Id.

### Parameters:

- ****`clientId`**** (string): ID of the client.
- **`chainId`** (number): Chain Id.
- **`page`** (number | undefined): page number.

### Usage

```jsx
let alert = await mempools.getAlerts(clientId);
```

### Enable Alert

****`enableAlert(alertId: string): Promise<SuccessType | ErrorType>`****

Enables a previously disabled alert.

### Parameters:

- **`alertId`** (string): ID of the alert to disable.

### Usage

```jsx
let alert = await mempools.enableAlert(alertId);
```

### Disable Alert

****`disableAlert(alertId: string): Promise<SuccessType | ErrorType>`****

Disables an existing alert.

### Parameters:

- **`alertId`** (string): ID of the alert to disable.

### Usage

```jsx
let alert = await mempools.disableAlert(id);
```

### Delete Alert

****`deleteAlert(alertId: string): Promise<SuccessType | ErrorType>`****

Deletes an alert.

### Parameters:

- **`alertId`** (string): ID of the alert to disable.

### Usage

```jsx
let alert = await mempools.deleteAlert(id);
```

## Cosmos Blockchain methods

### Cosmos Monitor Alert

****`cosmosMonitorFundsAlert(monitorAlert: MonitorAlertType): Promise<SuccessType | ErrorType>`****

Creates an alert to monitor funds for a specific address on the Cosmos blockchain.

### Parameters:

- **`userId`** (string): User ID associated with the alert.
- **`addressToMonitor`** (string): Address to monitor for fund movements.
- **`chainId`** (string): Chain Id.

### **Usage**

```jsx
let alert = await mempools.cosmosMonitorFundsAlert({
	userId: "USER_ID",
	addressToMonitor: "ADDRESS_TO_MONITOR"
});
```

## Cosmos Monitor Smart Contract

****`cosmosMonitorSmartContractAlert(smartContractAlert: MonitorSmartContractAlertType): Promise<SuccessType | ErrorType>`****

Creates an alert to monitor smart contract events on the Cosmos blockchain.

### Parameters:

- **`userId`** (string): User ID associated with the alert.
- **`contractAddress`** (string): Address of the smart contract to monitor.
- **`eventName`** (string): Name of the smart contract event to monitor.
- **`smartContractEvents`** (array, optional): An array of smart contract event objects.
- **`chainId`** (string): Chain Id.

### **Usage**

```jsx
let alert = await mempools.cosmosMonitorSmartContractAlert({
	userId: "USER_ID",
	contractAddress: "SC_CONTRACT_ADDRESS",
	eventName: "EVENT_NAME",
	smartContractEvents: "SC_EVENTS"
});
```

## EVM Blockchain methods

### EVM Monitor Alert

****`evmMonitorFundsAlert(monitorAlert: MonitorAlertType): Promise<SuccessType | ErrorType>`****

Creates an alert to monitor funds for a specific address on the EVM blockchain.

### Parameters:

- **`userId`** (string): User ID associated with the alert.
- **`addressToMonitor`** (string): Address to monitor for fund movements.
- **`chainId`** (string): Chain Id.

### **Usage**

```jsx
let alert = await mempools.evmMonitorFundsAlert({
	userId: "USER_ID",
	addressToMonitor: "ADDRESS_TO_MONITOR"
});
```

### EVM Monitor Smart Contract

****`evmMonitorSmartContractAlert(smartContractAlert: MonitorSmartContractAlertType): Promise<SuccessType | ErrorType>`****

Creates an alert to monitor smart contract events on the EVM blockchain.

### Parameters:

- **`userId`** (string): User ID associated with the alert.
- **`contractAddress`** (string): Address of the smart contract to monitor.
- **`contractAbi`** (string): Smart Contract Abi.
- **`eventName`** (string): Name of the smart contract event to monitor.
- **`smartContractEvents`** (array, optional): An array of smart contract event objects.
- **`chainId`** (string): Chain Id.

### **Usage**

```jsx
let alert = await mempools.evmMonitorSmartContractAlert({
	userId: "USER_ID",
	contractAddress: "SC_CONTRACT_ADDRESS",
	eventName: "EVENT_NAME",
	smartContractEvents: "SC_EVENTS"
});
```

---
_Source: https://npm.io/package/mempools-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
