This SDK was created to run on node js applications. If you want to use it in a frontend application you must install: https://www.npmjs.com/package/mempools-sdk
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.
You can install the mempools-sdk
package using npm:
npm install mempools-sdk
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";
The Cosmos SDK methods will return one of two types: ErrorType
or SuccessType
.
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.
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.
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.
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.
getAlerts({clientId: string, chainId: string, page?: number}): Promise<SuccessType | ErrorType>
Get all alerts from a client Id.
-
clientId
(string): ID of the client. -
chainId
(number): Chain Id. -
page
(number | undefined): page number.
let alert = await mempools.getAlerts(clientId);
enableAlert(alertId: string): Promise<SuccessType | ErrorType>
Enables a previously disabled alert.
-
alertId
(string): ID of the alert to disable.
let alert = await mempools.enableAlert(alertId);
disableAlert(alertId: string): Promise<SuccessType | ErrorType>
Disables an existing alert.
-
alertId
(string): ID of the alert to disable.
let alert = await mempools.disableAlert(id);
deleteAlert(alertId: string): Promise<SuccessType | ErrorType>
Deletes an alert.
-
alertId
(string): ID of the alert to disable.
let alert = await mempools.deleteAlert(id);
cosmosMonitorFundsAlert(monitorAlert: MonitorAlertType): Promise<SuccessType | ErrorType>
Creates an alert to monitor funds for a specific address on the Cosmos blockchain.
-
userId
(string): User ID associated with the alert. -
addressToMonitor
(string): Address to monitor for fund movements. -
chainId
(string): Chain Id.
let alert = await mempools.cosmosMonitorFundsAlert({
userId: "USER_ID",
addressToMonitor: "ADDRESS_TO_MONITOR"
});
cosmosMonitorSmartContractAlert(smartContractAlert: MonitorSmartContractAlertType): Promise<SuccessType | ErrorType>
Creates an alert to monitor smart contract events on the Cosmos blockchain.
-
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.
let alert = await mempools.cosmosMonitorSmartContractAlert({
userId: "USER_ID",
contractAddress: "SC_CONTRACT_ADDRESS",
eventName: "EVENT_NAME",
smartContractEvents: "SC_EVENTS"
});
evmMonitorFundsAlert(monitorAlert: MonitorAlertType): Promise<SuccessType | ErrorType>
Creates an alert to monitor funds for a specific address on the EVM blockchain.
-
userId
(string): User ID associated with the alert. -
addressToMonitor
(string): Address to monitor for fund movements. -
chainId
(string): Chain Id.
let alert = await mempools.evmMonitorFundsAlert({
userId: "USER_ID",
addressToMonitor: "ADDRESS_TO_MONITOR"
});
evmMonitorSmartContractAlert(smartContractAlert: MonitorSmartContractAlertType): Promise<SuccessType | ErrorType>
Creates an alert to monitor smart contract events on the EVM blockchain.
-
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.
let alert = await mempools.evmMonitorSmartContractAlert({
userId: "USER_ID",
contractAddress: "SC_CONTRACT_ADDRESS",
eventName: "EVENT_NAME",
smartContractEvents: "SC_EVENTS"
});