On the wave of the Bitcoin and alt-coins hype, I think it’s worth to ask yourself a question: Can something be done to get Bitcoin for free? Well the answer is simple: Yes you can! With the support of modern programming language, you can generate some coins in no time using the Bitcoin bot. It’s a great way to start your adventure with Bitcoin without putting your budget at risk. Don’t expect golden mountains though – it’s more a programming challenge/fun project than new way of getting rich but with proper scale. Here’s the complete guide how to setup your Bitcoin bot, but before we got down to business let’s talk about problems and theory.

Bitcoin Faucets

So how does it work? Everybody keeps on saying that you have to throw some cash into this insecure, unknown and hazardous machine, some sorcery happens and ta-daaa – you own virtual money. You wouldn’t risk your hard earned cash with something like this, right? Well, there’s a way to avoid uncertainty. Bitcoins and alt-coins (such as DOGE, Litecoin, DarkCoin) are mined by people with serious graphics card (and I mean serious – like plane hangars full of GPUs).

Fortunately some guys found a way to share satoshi (1/100000000 of Bitcoin) with people visiting their sites. Mechanism is simple, you create a webpage packed with ads and pay users for visiting (and earn revenue from ads providers). Such pages are called Faucets. There are separate faucets for each of coin. I believe you already know what is going to happen next. It’s time to write bitcoin bot which will perform all needed actions to earn bitcoins. Sounds simple? It ain’t that easy. Faucet owners are no stupid and protect their sites from bots. Usually with captchas. The more sophisticated captcha, the harder it gets to earn satoshi with bot (and to get profit).

Captcha problem

It’s easy to solve solveMedia type captcha when siting in front of monitor. Those are usually distorted sentences and human should fairly easy recognize them.But how bot will read this text? It won’t. There are multiple services that solves catpchas for you for a small fee. I’ve chosen 9kw.eu as it can be free – you can solve captchas to earn credits which can be later spent on you requests. More advanced captchas like famous Google’s recaptcha2 can be solved with 2captcha.com but this service is slow and it’s not worth it.

Payout problem

Some faucets function as a separate entity in the Internet. In most cases those sites are scams and promise payout after reaching certain satoshi threshold. In practice your account will be banned before you reach that level. To solve that problem and to gather more people, faucet owners started to organize themselves. One of the biggest and best grouping site is faucethub.io. It provides lot of faucets for major coins. You can play games and manually visit faucets to earn more coins apart of bot. Be aware though – they can ban you due to suspicious activity (like playing whole day without rest using bitcoin bot).

Creating The Bitcoin Bot

Now, after some theory, it’s time to actually build something. Here’s what you will need:

new email (there are a lot of scams ahead)

bitcoin wallet

FaucetHub Account

9kw account

node.js installed

phantom and casperjs installed

Bitcoin Bot code

I will skip email creation part as it’s pretty simple 🙂 I assume that you know how to create a separate email if you are trying to write a Bitcoin bot.

Bitcoin Wallet

This is the most important thing in this whole Bitcoin Bot process. In general, there are 2 kinds of Bitcoin wallets: hardware and software. Hardware wallets come in different way – as a USB key or printed QR code. They are considered the most secure and therefore I would suggest using one. The most basic is the paper wallet. You can print you own at Wallet Generator Site. If you have at least minimal trust in people you can use software wallet but you want to stick with the ones giving you access to your private key. It’s simple: having your private key or seed you can replicate your wallet on any other device. If you don’t own keys (like for example in Bitcoin exchange portals) then provider can simply close the site and your coin is gone. And there’s no way to get it back. Literally. For my personal use I chosen Copay Android app as it stores keys on the device. Whichever approach you chose, you should have 33 or 34 chars long address like this:

1AVNfQQjEJCmst83oQH6RJUpbqkHZWe1W7

This is the public address and it’s safe to share it. Never share private address as it can be used for hacking your wallet.

FauceHub Account

9kw account

Go to 9kw and create new account there. After you’re done, go ahead and click Captcha tab at the top and solve couple of captchas:

Just enter correct answer in the field below and you should see your balance on the right increase. For single bot run you will need ~30 credits.

node.js

Now let’s talk about programming environment. I an Javascript guy so naturally I’ve chosen the JS-like language to work with. Node.js is not really needed here as Casperjs is a standalone product, but npm installations is easier with node.js on board.

Go to https://nodejs.org/en/download/ , download package for your OS and them install it. Make sure you know where it installs – you will need that directory. To make sure that your system recognizes node.js and npm commands, PATH needs to be updated.

To update PATH Variables in Windows 7 click Start> Right click on Computer > Properties > Advanced System Setting > Advanced Tab > Environment Variables. For the PATH variable scroll down to Path and edit it by adding path to just installed node.js. In my case it’s c:\software\nodejs. Be sure to precede and follow this entry with semicolon.

phantomjs and casperjs

PhantomJS and CaperJS are framework based on node.js which allows to emulate behavior of the user in the browser. Those are so called headless browsers which means that they don’t display any GUI while operating. As you might imagine this will be the foundation for Bitcoin bot.

Let’s start with phantom. Go to http://phantomjs.org/download.html and download proper package for your operating system. Install it and add phantom.exe location to path variable. in my case it was C:\PhantomJS\bin\phantomjs.

Now let’s proceed with Casperjs. On http://casperjs.org/ you can find different ways to install casperjs but thanks to just installed node.js we can use npm installer. Fire up command line and run

npm install casperjs

By default this should install casperjs in node.js modules directory. As in the previous cases, you need to add that directory to PATH variables. In my case it was C:\Software\nodejs;C:\Software\nodejs\node_modules\casperjs\bin\

By now you should have everything setup. Let’s check if casper is visible in your system. Bring up command prompt and enter

casperjs --version

This should output in casperjs version.

Bitcoin Bot Code

Here comes the real stuff. For this tutorial I’ve chosen BitLucky.io faucet as it covers actions common in other faucets.

When you go to the site, you easily notice that there’s a set of actions that needs to be done to get satoshi.

enter bitcoin wallet

click login

solve captcha

click claim

withdraw

Here’s my sample code which covers all of those steps. Please note variables section at the top and follow commented lines for more instructions. Click to expand the whole code:

What’s going on here? Here’s the quick overview of functions used in Bitcoin bot:

kwsolver – accepts saved captcha image, pushes it to the 9kw service, waits certain moment of time for answer and returns answer in text file

cleaner – cleans all files (mostly images) generated by the script

generateTimestamp – outputs time in various format. Usable in debugging and showing next run time

When you inspect the code, it’s pretty straightforward what does it do. There are steps within .then() statements that are run one by one. One aspect that might be new is site object reference like this:

document.getElementById('button').click();

It’s just a handler reference. It can be found by Inspecting the webpage in browser:

What you might find strange is this JANUVIA. This is kind of a hack for common captcha that appeared for my Bitcoin bot. It looks like this:

Unfortunately 9kw service couldn’t handle that correctly so I was wasting credits on this. To solve this problem, I’ve added md5 hash checker which checks if image hash is the same as this one and bypasses 9kw service by providing correct security code which in this case is always Januvia. This workaround can be expanded for other common captchas. You just need to catch the generated md5hash and add it to kwsolver function.

Running the Bitcoin bot

So we know the theory, we have the code, let’s run it. Simply copy the code above, save it to a .js (for example to bitlucky_io.js) file and using the command prompt run (remember to be in folder where file is located)

casperjs bitlucky_io.js

You will see a lot of status updates – those are controlled by console.log() function. There are also image files generated in the same folder. Those will help you debug the script as it saves exactly the same webpage as seen by your browser.

I allowed the script to run and it looks like I was lucky. I managed to get satoshi from the faucet and thankt to Januvia hack I didn’t even spent 9kw credits on that.

Withdrawal

As you might noticed, there’s a balance indicator in the script. Bitlucky keeps your claimed satoshi on the internal balance account. It looks like the case I’ve described in the Payout problem part above. Fortunately you can withdraw coins at any time. And yes, you can write a separate script which will do it for you automatically. Funds withdrawn that way are transferred to your FaucetHub account and then can be withdrawn to Bitcoin wallet.