Skip to content

feat(example): add discord wallet tracker bot #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

KelvinTrinhSG
Copy link

Description

This PR adds a new example: Discord Wallet Tracker Bot — a TypeScript/Node.js application that listens to BNB Chain wallet transactions and posts real-time alerts to a specified Discord channel.

It uses:

  • BscScan API to poll for new transactions
  • Discord.js to format and send alerts
  • dotenv for environment configuration
  • Web3.js for BNB unit conversions

This example helps developers learn how to build blockchain-integrated bots that communicate directly with communities.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Set up the project locally using npm install and created a valid .env file based on .env.example with real credentials:

    • Discord bot token with message permissions
    • Target Discord channel ID
    • BscScan API key
    • A BNB wallet address to monitor
  • Ran the bot using npx ts-node index.ts in development mode.

  • Simulated both incoming and outgoing transactions on the monitored wallet:

    • Sent BNB to the wallet using another wallet
    • Sent BNB from the wallet to another address
  • Verified that:

    • The bot detected new transactions every 10 seconds
    • Incoming and outgoing directions were correctly classified
    • The value (in BNB) was accurate
    • A well-formatted message was sent to the specified Discord channel including:
      • Sender/receiver addresses
      • BNB amount
      • Timestamp
      • A direct BscScan link to view the transaction
  • Confirmed the bot remained stable after multiple transactions and had no crash or warning during runtime.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my feature works
  • New and existing unit tests pass locally with my changes

@KelvinTrinhSG
Copy link
Author

image
Here's a screenshot showing the bot working with Discord after successful testing:

```

> ✅ Make sure your Discord bot has permissions to **read and send messages** in the target channel.
> ✅ You can get a free BscScan API key at [https://bscscan.com/myapikey](https://bscscan.com/myapikey)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m

@@ -0,0 +1,140 @@
# 🤖 BSC Smart Contract Risk Agent
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not related to adding the Discord example — if it is, please remove it. Thanks.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
I have removed the meme icon. Thanks.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the Discord wallet example, the Python files probably aren't necessary, right?

}
}

// Check mỗi 10 giây
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English, please

Copy link
Author

@KelvinTrinhSG KelvinTrinhSG Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed the Vietnamese comment.

"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add your scripts here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
I have updated the script.
Thanks.

@@ -0,0 +1,42 @@
require("dotenv").config();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this file?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is used during development and debugging to watch wallet activity in real-time without running the main Discord bot logic. It polls the BscScan API every 10 seconds to detect new transactions on the specified wallet and logs the details to the console.

If you think this file is not necessary, I’m happy to remove it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can use tsx instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants