A Telegram bot for betting ICP tokens on emoji dice games. Players type a bet amount, pick a game, and win or lose based on the roll result.
- Player sends a bet amount (in $ICP) to the bot in the game thread
- The bot checks the player's balance on the ICP ledger via ICRC-1
- Player selects a game from the inline keyboard
- The bot sends a Telegram dice animation in the selected game
- Win/loss is determined by the roll value, and ICP is transferred accordingly
| Game | Emoji | Win Condition | Odds | Multiplier |
|---|---|---|---|---|
| Dice | 6 | Roll 6 | 1 in 6 | 5x |
| Darts | 6 | Roll 6 | 1 in 6 | 5x |
| Bowling | 6 | Roll 6 | 1 in 6 | 5x |
| Soccer | 5 | Roll 5 | 1 in 5 | 4x |
| Basketball | 5 | Roll 5 | 1 in 5 | 4x |
| Slot Machine | 64 | Roll 64 | 1 in 64 | 10x |
- Language: Rust
- Telegram Bot: teloxide 0.12
- Async Runtime: tokio
- Ledger: ICP via ICRC-1 (calls
dfx canister call --ic) - Number Formatting: numfmt
- Rust toolchain (latest stable)
dfx(ICP Canister SDK) installed and configured- A Telegram bot token (from @BotFather)
- An ICP ledger canister ID (
ryjl3-tyaaa-aaaaa-aaaba-caion mainnet) - A
TREASURYdfx identity with funds for paying out winnings
Open src/main.rs and set your values:
let bot = Bot::new("YOUR_TELEGRAM_BOT_TOKEN");
const TREASURY_PRINCIPAL: &str = "YOUR_TREASURY_WALLET_PRINCIPAL";
const TREASURY_IDENTITY: &str = "TREASURY"; // dfx identity name
const GAME_THREAD_ID: i64 = YOUR_FORUM_THREAD_ID;
const GAME_CHAT_ID: i64 = YOUR_CHAT_ID;cargo build --release
cargo run --releaseThe bot listens for messages in the configured chat and thread. Players interact entirely through the Telegram UI.
icp_gamebot/
├── Cargo.toml
├── README.md
└── src/
└── main.rs # All bot logic: message handling, game dispatch, ICP transfers
- Bets are transferred from the player to the treasury before the game
- Winnings are transferred from the treasury to the player on a win
- Losses stay in the treasury
- All transfers use
dfx canister call --ic ryjl3-tyaaa-aaaaa-aaaba-cai icrc1_transfer - Balances are checked via
icrc1_balance_of
MIT