Skip to content

itcodehery/sidebet-monad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Win for the Books!

Sidebet-Monad won the third prize at the second Monad Blitz, Bangalore Hackathon organised by the Monad Foundation.

"Turn trash talk into real stakes."

Drop a /sidebet in your group chat — settle it with crypto. No spreadsheets. No Discord mods. Just pure, social speculation — on-chain and on demand.

Sidebets Telegram Bot

A Telegram bot for creating and participating in prediction markets on Monad blockchain.

Features

  • 🔗 Wallet Connection: Each user gets their own wallet
  • 🎯 Market Creation: Users can create prediction markets with custom stakes
  • 💰 Betting: Place bets using your own funds
  • 🏆 Claim Rewards: Winners can claim their share of the pot
  • 👥 Multi-user: Each user manages their own wallet and funds

Setup

  1. Install dependencies:

    npm install
  2. Configure environment:

    cp .env.example .env
    # Edit .env with your values
  3. Required environment variables:

    • TELEGRAM_BOT_TOKEN: Your Telegram bot token
    • CONTRACT_ADDRESS: Deployed SidebetsFactory contract address
    • RPC_URL: Blockchain RPC endpoint
    • ADMIN_PRIVATE_KEY: Private key for market resolution (oracle)
    • ADMIN_IDS: Comma-separated Telegram user IDs for admins
  4. Deploy the contract: Deploy MyContract.sol and set the contract address in .env

  5. Run the bot:

    npm start

How It Works

For Users:

  1. Connect Wallet (/wallet)

    • Bot generates a unique wallet for each user
    • User receives wallet address and private key
    • User must fund the wallet with MON tokens
  2. Create Markets (/sidebet <amount> <question>)

    • Example: /sidebet 0.1 Will it rain tomorrow?
    • Uses user's own funds for the stake
  3. Place Bets (/bet <market_id> <yes/no>)

    • Example: /bet 0 yes
    • Deducts stake from user's wallet
  4. Claim Winnings (/claim <market_id>)

    • Winners claim their share after resolution

For Admins:

  • Resolve Markets (/resolve <market_id> <yes/no>)
    • Only admins can resolve markets
    • Uses oracle functionality from the contract

Commands

Command Description Example
/wallet Connect your wallet /wallet
/status Check wallet status /status
/sidebet Create a market /sidebet 0.1 Will BTC hit 100k?
/markets List active markets /markets
/bet Place a bet /bet 0 yes
/claim Claim winnings /claim 0
/resolve Resolve market (admin) /resolve 0 yes
/debug Show technical info /debug
/help Show help message /help

Security Notes

⚠️ Important Security Considerations:

  1. Private Keys: In this demo, private keys are logged to console. In production:

    • Use secure key management
    • Implement proper wallet connect protocols
    • Never log private keys
  2. Wallet Generation: Currently generates random wallets. In production:

    • Integrate with MetaMask/WalletConnect
    • Use hardware wallets for admin functions
    • Implement proper authentication
  3. Admin Functions: Admin private key should be:

    • Stored securely (not in .env in production)
    • Use hardware wallet or secure key management
    • Rotated regularly

Contract Integration

The bot integrates with two smart contracts:

  1. SidebetsFactory: Creates and manages markets
  2. PredictionMarket: Individual market contracts for betting

See MyContract.sol for the complete contract implementation.

Development

# Development mode with auto-restart
npm run dev

Troubleshooting

  1. "Wallet not connected": Use /wallet to connect first
  2. "Insufficient balance": Fund your wallet with MON tokens
  3. "Contract rejected": Check if market is still active
  4. "Not authorized": Only admins can resolve markets

License

MIT

About

(Web3 + Telegram Bot) Turn trash talk into real stakes

Topics

Resources

Stars

Watchers

Forks