npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

custodial-wallet

v1.0.3

Published

This Node.js application tracks native cryptocurrency balances (such as ETH, BNB, MATIC, TRX) and specific token balances (ERC-20, BEP-20, TRC-20) for given wallet addresses on Ethereum, Binance Smart Chain (BSC), Polygon, and Tron networks.

Downloads

20

Readme

Create EVM & Tron Wallet and Track Balance

This Node.js application tracks native cryptocurrency balances (such as ETH, BNB, MATIC, TRX) and specific token balances (ERC-20, BEP-20, TRC-20) for given wallet addresses on Ethereum, Binance Smart Chain (BSC), Polygon, and Tron networks.

Features

  • Wallet Creation: Generate new wallet addresses for Ethereum-compatible (BSC, Polygon) and Tron networks.
  • Native Balance Tracking: Track the native cryptocurrency balances (ETH, BNB, MATIC, TRX) of specific wallet addresses.
  • Token Balance Tracking: Track balances of specific tokens (ERC-20, BEP-20, TRC-20) for specified wallet addresses.
  • Automatic Payment Tracking: Automatically track incoming payments and token balances.

Technologies Used

  • Node.js: Backend framework for running the server.
  • Express.js: Web framework for handling HTTP requests.
  • ethers.js: Library for interacting with Ethereum-compatible blockchains (BSC, Polygon).
  • TronWeb: Library for interacting with the Tron blockchain.

Installation

  1. Install package:

    npm i custodial-wallet
  2. Install dependencies:

    npm install
  3. Start the server:

    node index.js

    The server will start running on http://localhost:3000.

API Endpoints

1. Create Wallet

  • URL: /create-wallet
  • Method: GET
  • Description: Generates new wallet addresses for Ethereum-compatible networks (BSC, Polygon) and Tron network.

Example Response:

{
    "bsc": {
        "address": "0xYourBscOrPolygonAddress",
        "privateKey": "YourPrivateKey"
    },
    "polygon": {
        "address": "0xYourPolygonAddress",
        "privateKey": "YourPrivateKey"
    },
    "tron": {
        "address": "TYourTronAddress",
        "privateKey": "YourPrivateKey"
    }
}

2. Start Tracking

  • URL: /start-tracking

  • Method: GET

    • Query Parameters: address: The Ethereum/BSC/Polygon wallet address. tronAddress: The Tron wallet address. tokenAddress: The smart contract address of the token you want to track. tokenType: The type of token (ERC20, BEP20, TRC20).

    Description: Starts tracking native and token balances for the specified wallet addresses.

Example Request:


GET /start-tracking?address=0xYourBscOrPolygonAddress&tronAddress=YourTronAddress&tokenAddress=0xYourTokenAddress&tokenType=ERC20

Example Response:


{
    "message": "Started tracking payments and token balance for address 0xYourBscOrPolygonAddress",
    "balances": {
        "bsc": "0.1234",
        "polygon": "0.5678",
        "tron": "9.8765",
        "token": "1000.00"
    }
}

3. Check All Balances

  • URL: /check-all-balances

  • Method: GET

  • Query Parameters:

    • address: The Ethereum/BSC/Polygon wallet address.
    • tronAddress: The Tron wallet address.
    • tokenAddress: The smart contract address of the token you want to track.
    • tokenType: The type of token (ERC20, BEP20, TRC20).

    Description: Manually checks and returns the current balances for native currencies and specified tokens.

Example Request:


GET /check-all-balances?address=0xYourBscOrPolygonAddress&tronAddress=YourTronAddress&tokenAddress=0xYourTokenAddress&tokenType=ERC20

Example Response:


{
    "message": "Balances for address 0xYourBscOrPolygonAddress",
    "balances": {
        "bsc": "0.1234",
        "polygon": "0.5678",
        "tron": "9.8765",
        "token": "1000.00"
    }
}

4. Tracking Payments

The server will automatically track and log new payments and token balance changes every minute.

  • Polling Interval: Every 60 seconds.

How It Works

  • Create Wallets: You can generate new wallet addresses for BSC, Polygon, and Tron using the /create-wallet endpoint.
  • Start Tracking: Start tracking a wallet's native and token balances using the /start-tracking endpoint.
  • Check Balances: Manually check all balances using the /check-all-balances endpoint.
    • ** Automatic Tracking:** The server checks for new payments and token balance changes every minute and logs any changes.

Limitations

  • The application currently tracks only one token at a time per request.
  • For tracking multiple tokens automatically, integration with an external service like Etherscan or BscScan would be required to fetch all tokens associated with a wallet.

Future Enhancements

  • Automatic tracking of all tokens held by a wallet address.
  • Integration with external APIs to fetch and display all tokens associated with a wallet.
  • Enhanced error handling and logging.

Author

@nadcablabs