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
-
Clone the repository:
git clone https://github.com/yourusername/blockchain-balance-tracker.git
cd blockchain-balance-tracker
-
Install dependencies:
npm install
-
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
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
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