New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

maswallet-nodejs

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

maswallet-nodejs

A Node.js SDK for interacting with the MasWallet API

latest
npmnpm
Version
1.1.0
Version published
Maintainers
0
Created
Source

MasWallet Node.js SDK

A Node.js SDK for interacting with the MasWallet API. This SDK provides an easy-to-use wrapper for developers to integrate MasWallet's blockchain services into their applications.

Features

  • Simplified access to MasWallet API endpoints.
  • Supports both TypeScript and JavaScript.
  • Fully typed for a better developer experience.
  • Built-in error handling.
  • Supports customizable configurations.

Installation

npm install maswallet-nodejs

or

yarn add maswallet-nodejs

Quick Start

Import the SDK

// Using TypeScript or ES Module
import { ApiClient } from 'maswallet-nodejs';

// Using CommonJS
const { ApiClient } = require('maswallet-nodejs');

Initialize the Client

const client = new ApiClient({
  apiClientId: '<YOUR_API_KEY>',
  apiClientSecret: '<YOUR_API_SECRET>',
  baseUrl: 'https://wallet-api.maschain.com', // Optional: defaults to MasWallet's official base URL
});

Example Usage

Create a Transaction

const transaction = await client.createTransaction({
  walletAddress: '<WALLET_ADDRESS>',
  contractAddress: '<CONTRACT_ADDRESS>',
  abiFunction: '<ABI_FUNCTION>',
  functionArgs: ['<FUNCTION_ARG_1>', '<FUNCTION_ARG_2>'],
  redirectUrl: '<REDIRECT_URL>', // Optional: defaults to the current URL
});
console.log(transaction);

Documentation

Methods

createTransaction(params: TransactionParams): Promise<TransactionResponse>

Creates a new transaction on the MasWallet blockchain.

getTransaction(transactionId: string): Promise<TransactionDetails>

Retrieves details of a specific transaction.

For full method documentation, refer to the API Documentation.

Configuration

The ApiClient supports the following configuration options:

OptionTypeDefaultDescription
apiClientIdstringundefinedYour MasWallet API client ID.
apiClientSecretstringundefinedYour MasWallet API client secret.
baseUrlstringhttps://api.maschain.com/apiBase URL for the MasWallet API.
timeoutnumber5000Request timeout in milliseconds.

Error Handling

Errors thrown by the SDK are instances of MasWalletError, which provides the following properties:

  • code: Error code returned by the API.
  • message: A descriptive error message.
  • details: Additional error information (if any).

Example

try {
  const transaction = await client.createTransaction({ ... });
} catch (error) {
  if (error instanceof MasWalletError) {
    console.error('Error Code:', error.code);
    console.error('Error Message:', error.message);
  } else {
    console.error('An unexpected error occurred:', error);
  }
}

Keywords

maswallet

FAQs

Package last updated on 13 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts