Skip to content

c4nl/Search-MM-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’± Search MM Bot

A transparent, fully-logged Discord Middleman Bot with real multi-chain crypto escrow.

Search MM Bot

Inspired by tip.cc and Halal MM β€” built cleaner, cheaper, and fully open source.


πŸ“– Table of Contents


✨ Features

Feature Description
🏦 Real On-Chain Escrow Every deal uses a freshly generated wallet. Funds live on-chain, not in a database.
πŸ”’ Both-Party Confirmation Funds are only released when both the sender and receiver confirm the deal.
⚠️ Dispute System Either party can open a dispute. Staff can force-release funds to the correct party.
πŸ“£ Staff Ping One-click button to alert staff inside any ticket.
πŸ“‹ Full Logging Every action (payment received, confirmation, dispute, force-release) is logged to a Discord channel and the database.
πŸ“œ Transcripts Full ticket transcripts are automatically posted to a transcript channel when a deal closes.
♻️ Ticket Restoration If the bot or server is deleted, re-inviting the bot rebuilds all active tickets with full message history replayed via webhooks.
πŸ“Š Global Stats & Leaderboard /stats and /leaderboard track deal counts and USD volume across every server.
πŸ… Auto Roles Users automatically receive roles when they hit configurable USD volume thresholds (e.g. $1,000, $10,000).
πŸ’± 9 Crypto Assets BTC, ETH, LTC, SOL, USDT & USDC across ERC-20, BEP-20, and Solana.
πŸ’° Lower Fees Cheaper than the original β€” see fee table below.

πŸ’± Supported Cryptocurrencies

Asset Network Symbol
Bitcoin Bitcoin BTC
Ethereum Ethereum (ERC-20) ETH
Litecoin Litecoin LTC
Solana Solana SOL
Tether Ethereum (ERC-20) USDT
USD Coin Ethereum (ERC-20) USDC
Tether Solana (SPL) USDT
USD Coin Solana (SPL) USDC
Tether BNB Chain (BEP-20) USDT

🧾 Fee Structure

Fees are lower than the original Halal MM Bot.

Deal Size Fee
$250 and above 0.75% (original: 1%)
$50 – $249.99 $1.50 flat (original: $2)
Under $50 FREE
USDT / USDC +$0.75 stablecoin surcharge on paid deals (original: $1)

Example: A $500 ETH deal costs $3.75. A $100 USDT deal costs $1.50 + $0.75 = $2.25.


πŸ“Ÿ Commands

User Commands

Command Description
/mm Open a new middleman deal via crypto dropdown
/stats [@user] View your total deals and USD volume (or another user's)
/leaderboard Global top 10 traders ranked by USD volume
/ticket info View details about the current ticket
/ticket transcript Manually generate a transcript for the current ticket

Admin Commands

Command Description
/setup Configure staff role, completed channel, log channel, and transcript channel
/panel Post the crypto selection panel in the current channel
/admin stats View bot-wide statistics (total deals, volume, active tickets, staff interventions)
/admin forcerelease <ticket_id> <user> Force-release disputed funds to a specific user
/admin cancel <ticket_id> Cancel a ticket

πŸ”„ How a Deal Works

1. Sender runs /mm or uses the panel dropdown
   └─ Selects cryptocurrency

2. Modal appears β€” sender enters:
   └─ Receiver's Discord User ID
   └─ Amount to send

3. Bot creates a private ticket channel
   └─ Only sender, receiver, and staff can see it
   └─ Bot generates a fresh escrow wallet address
   └─ Deposit instructions sent with the escrow address

4. Sender sends crypto to the escrow address
   └─ Bot polls on-chain every 30 seconds
   └─ Payment confirmed automatically

5. Both parties press βœ… Confirm Deal
   └─ Funds are released to receiver on-chain
   └─ Deal posted to #completed-deals channel (anonymised)
   └─ Full transcript saved to #transcripts
   └─ Ticket channel deleted after 30 seconds

ALTERNATIVELY β€” if something goes wrong:
   └─ Either party opens a dispute ⚠️
   └─ Staff are pinged automatically
   └─ Staff review and use /admin forcerelease

πŸš€ Installation

Prerequisites

  • Node.js v18+ β€” Download
  • A Discord Bot β€” Discord Developer Portal
  • Alchemy or Infura account β€” for ETH/BSC RPC (free tier works)
  • BlockCypher account β€” for BTC/LTC monitoring (free tier works)

1. Clone the Repository

git clone https://github.com/yourusername/Search-mm-bot.git
cd Search-mm-bot

2. Install Dependencies

npm install

3. Configure Environment

cp .env.example .env

Then open .env and fill in your values (see Configuration below).

4. Start the Bot

npm start

For development with auto-restart:

npm run dev

βš™οΈ Configuration

All configuration is done in .env. Here's what each variable does:

# ── Discord ──────────────────────────────────────────
DISCORD_TOKEN=        # Your bot token from Discord Dev Portal
CLIENT_ID=            # Your application/client ID
GUILD_ID=             # (Optional) Set for instant dev commands in one server

# ── Security ─────────────────────────────────────────
ENCRYPTION_KEY=       # 32+ char random string β€” encrypts all private keys
                      # Generate: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"

# ── RPC Providers ─────────────────────────────────────
ETH_RPC=              # Alchemy or Infura Ethereum endpoint
BSC_RPC=              # BNB Chain RPC (default: public Binance node)
SOL_RPC=              # Solana RPC (default: public mainnet endpoint)

# ── BTC / LTC Monitoring ──────────────────────────────
BLOCKCYPHER_TOKEN=    # Free at blockcypher.com β€” used to check BTC/LTC balances

# ── Network ───────────────────────────────────────────
NETWORK=mainnet       # mainnet or testnet

Getting Your API Keys

Key Where to Get It
DISCORD_TOKEN Discord Dev Portal β†’ Your App β†’ Bot β†’ Reset Token
CLIENT_ID Dev Portal β†’ Your App β†’ General Information β†’ Application ID
ETH_RPC Alchemy β†’ Create App β†’ Ethereum β†’ Mainnet β†’ API Key
BLOCKCYPHER_TOKEN BlockCypher β†’ Register free
ENCRYPTION_KEY Run the command in the comment above β€” generate it yourself

πŸ–₯️ Self-Hosting

Discord Bot Setup

  1. Go to Discord Developer Portal
  2. Create a new application β†’ go to Bot tab
  3. Enable Message Content Intent under Privileged Gateway Intents
  4. Go to OAuth2 β†’ URL Generator
    • Scopes: bot, applications.commands
    • Bot Permissions:
      • Manage Channels
      • Manage Webhooks
      • Manage Roles
      • Send Messages
      • Embed Links
      • Read Message History
  5. Copy the generated URL and invite the bot to your server

Server Configuration

After inviting the bot, run in your server:

/setup
  staff_role: @YourStaffRole
  completed_channel: #completed-deals
  log_channel: #mm-logs
  transcript_channel: #transcripts

Then post the deal panel somewhere visible:

/panel

Role Thresholds (Optional)

To grant roles based on deal volume, add entries to the role_thresholds table in data/mm.db:

INSERT INTO role_thresholds (guild_id, min_usd, role_id)
VALUES ('YOUR_GUILD_ID', 1000, 'ROLE_ID_FOR_1K'),
       ('YOUR_GUILD_ID', 10000, 'ROLE_ID_FOR_10K'),
       ('YOUR_GUILD_ID', 50000, 'ROLE_ID_FOR_50K');

πŸ” Security

  • Private keys are never stored in plaintext. Every escrow wallet's key is encrypted with AES-256-GCM before being written to the database.
  • The ENCRYPTION_KEY is your master secret. If it is lost, no escrow funds can be recovered. Store it somewhere safe (e.g. a password manager or secret vault).
  • Back up data/mm.db regularly. It contains all deal data, messages, and encrypted keys.
  • Escrow wallets are single-use. A fresh address is generated per deal β€” no address reuse.
  • The bot never logs or prints private keys in plaintext under any condition.

⚠️ For production deployments with high volume, consider hardware key storage (HSM) or a secrets manager like HashiCorp Vault.


♻️ Ticket Restoration

If your server is deleted or the bot is kicked and re-invited:

  1. Re-invite the bot with the same token (or a new bot pointed at the same database)
  2. The bot detects all active tickets on guildCreate
  3. It automatically creates a ♻️ Restored Tickets category
  4. Each active ticket gets a new channel with all previous messages replayed via webhook β€” with original author names and avatars intact
  5. Deals continue exactly where they left off

This means no deal is ever lost due to a server or bot issue.


πŸ“ Project Structure

Search-mm-bot/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ index.js            # Bot entry point β€” client setup and interaction router
β”‚   β”œβ”€β”€ commands.js         # All slash command definitions
β”‚   β”œβ”€β”€ database.js         # SQLite schema and prepared statement queries
β”‚   β”œβ”€β”€ fees.js             # Crypto definitions and fee calculator
β”‚   β”œβ”€β”€ prices.js           # Live prices via CoinGecko (no API key needed)
β”‚   β”œβ”€β”€ wallets.js          # Multi-chain address generation, balance checks, fund forwarding
β”‚   β”œβ”€β”€ monitor.js          # On-chain payment polling for active tickets
β”‚   β”œβ”€β”€ ticketHandler.js    # Full ticket lifecycle (create, confirm, dispute, force-release)
β”‚   β”œβ”€β”€ embeds.js           # All Discord embed builders
β”‚   β”œβ”€β”€ logger.js           # Event logging to DB + Discord channel
β”‚   β”œβ”€β”€ restore.js          # Ticket channel restoration via webhooks
β”‚   └── roles.js            # Auto role assignment on volume milestones
β”œβ”€β”€ data/
β”‚   └── mm.db               # SQLite database (auto-created on first run)
β”œβ”€β”€ .env.example
β”œβ”€β”€ package.json
└── README.md

🀝 Contributing

Pull requests are welcome. For major changes, please open an issue first.

  1. Fork the repo
  2. Create a feature branch: git checkout -b feature/my-feature
  3. Commit your changes: git commit -m 'Add my feature'
  4. Push: git push origin feature/my-feature
  5. Open a pull request

πŸ“„ License

MIT β€” see LICENSE for details.


⚠️ Disclaimer

Read carefully before using this project.

This project is released as-is, for educational and personal use only.

  • I will not help you set up this bot
  • I will not help you configure it
  • I will not provide support, troubleshooting, or guidance of any kind
  • If you do not have the technical knowledge to run this independently, do not touch it

By cloning or running this software you acknowledge that you do so entirely at your own risk. I hold no liability for anything that happens to your Discord accounts, bots, servers, funds, or any third-party services as a result of using this project. This software handles real cryptocurrency β€” misconfiguration, misuse, or unexpected behaviour could result in financial loss or the permanent termination of your Discord account.

Do not open issues asking for help. They will be closed without response.


Built with ❀️ for transparent, trustless trading.

If this helped you, consider starring the repo ⭐

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors