Monthly Archives: June 2013

Coinroll.it Betting Bot – Martingale System

Hey everyone,

I received an odd request for a script the other day – a bot for an bitcoin gambling website. The request was for a simple JavaScript bookmarklet that would execute the martingale betting system autonomously.

The code I ended up with as follows:

1
javascript: /* MANUAL CONFIGURATION - Initialisation Only */ var reset_to = 0.00001; /* Amount to reset to */ /* Initialise bot */ initialise_bookmarklet(); var previous_bet = null; var bot_running = false; create_message('Bot initialised, hit run to start...'); /* Runs the bot */ function run_bot(){ /* Check to see whether bot needs to be run/stopped */ if(bot_running == true){ /* Create vars */ var bet_amount = $("#betamount").val(); var parent_id = $('#bets .item:first').attr('id'); var result = $('#bets .item:first-child .lucky'); /* Check if result is same as previous */ if(result == null || result.length == 0){ create_message('No bets on screen... waiting for next run.'); } else if(parent_id != previous_bet){ /* Set previous bet to current bet */ previous_bet = parent_id; /* Check the current bet amount */ if(bet_amount >= $('#max_bet').data('max_bet') || bet_amount > $('#account-balance').text()){ /* Reset bet amount */ $('#betamount').val(reset_to); create_message('<span style="font-weight:bold;color:red;">MAXXED OUT</span>'); } /* Check if first item is a win */ if($(result).hasClass('win')){ /* Adjust bet amount to reset amount and roll */ $('#betamount').val(reset_to); roll(); } else if($(result).hasClass('lose')){ /* Double amount and roll again */ setDouble(); roll(); } else{ create_message('Unknown status, not a win or loss... wait for next run...'); } } else if ($('#betbutton').hasClass('pressed') == false){ create_message('Assumed 503, press again...'); roll(); } else{ create_message('Previous bet is still there, wait ' + $('#bot_timeout').val() + 'ms...'); } /* Schedule next run */ setTimeout(function(){ run_bot(); }, $('#bot_timeout').val()); } else if(bot_running == false){ /* Update status to prevent bot running again */ create_message('Bot stopped...'); } else{ /* Error occurred */ create_message('Error: Unknown status.'); create_message('Bot stopped...'); } } /* Run when button clicked */ function bot_status_change(button){ /* Check whether to start or stop bot */ if(bot_running == false){ /* Run bot and display message */ create_message('Running bot...'); $(button).text('Pause'); bot_running = true; run_bot(); } else if(bot_running == true){ /* Update status to prevent bot running again */ create_message('Stopping bot...'); bot_running = false; $(button).text('Run'); } else{ /* Error occurred */ create_message('Error: Unknown status.'); create_message($(button).text('Run')); bot_running = false; } } /* Creates a message */ function create_message(message){ console.log(message); $('#status_div').prepend(message + '<br />'); } /* Sets the max bet */ function set_max_bet(){ /* Retrieve max bet */ var txt_max_value = parseFloat($.trim($('#max_bet').val())); /* Check if new bet is not a number */ if(isNaN(txt_max_value) == false){ /* Set max bet and display to user */ $('#max_bet').data('max_bet', txt_max_value); create_message('<b>New Max Bet: ' + txt_max_value + "</b>"); } else{ create_message('<p>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'); create_message('Max bet is not a number, not updated.'); create_message('Current Max Bet: ' + max_bet); create_message('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</p>'); } } /* Displays button to start bot etc */ function initialise_bookmarklet(){ /* Create vars */ var controls; var div_styles = "max-width:250px; width:250px;position: fixed; top: 10px; left: 10px; text-align: left; background-color: rgba(238, 238, 238, 0.84); padding: 10px; border: 1px solid rgba(116, 116, 116, 0.46); border-radius: 3px; box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.2); color: #333;"; var status_div = "<div id='status_div' style='font-size: 85%; max-width: 250px; position: fixed; bottom: 10px; left: 10px; text-align: left; background-color: rgb(15, 15, 15); padding: 10px; border: 1px solid rgba(31, 31, 31, 0.46); border-radius: 3px; box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.2); color: #1D9931; width: 250px; height: 200px; overflow: hidden;'></div>"; /* Set controls */ controls = "<div style='" + div_styles + "'>" + /* Wrapper start */ "Timeout: <br />" + "<input type='text' id='bot_timeout' value='500'/><button id='bookmarklet_controls' onClick='bot_status_change(this);'>Run</button><br />&nbsp;<br />" + /* Timeout button */ "Max Bet: <br />" + "<input type='text' id='max_bet' value='0.1' data-max_bet='0.1'><button id='btn_set_bet' onClick='set_max_bet();'>Set</button>" + /* Max Bet */ "&nbsp;<br /> <p style='margin-top:10px;'> Timeout: How many milliseconds the bot should wait between each bet. </p> <p style='margin-top:10px;'> Max Bet: The bot will revert to the reset amount if the bet exceeds this value (eg. 0.041) </p>" + "</div>"; /* Close wrapper */ /* Append status div */ controls += status_div; /* Add button to body */ $('body').append(controls); }

To add the bookmarklet, simply create a bookmark using the code above as the url. Go to CoinRoll, enter a bet and a starting value of 0.0001. Finally, click the bookmark icon, choose your max bet and hit start.

Martingale Bot for CoinRoll.it

Martingale Bot for CoinRoll.it

Note that this is just a quick script and has a lot of potential to be optimised. I should also mention that this is not an exploit, just a bot. The martingale system is still gambling and if you play long enough you WILL lose.