1.0.5 • Published 9 months ago

mempools-sdk v1.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

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:

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:

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

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

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

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

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

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

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

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

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

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

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago