How to Make Your First Bitcoin Application

Want to meet people building Bitcoin companies? Sign up for ZapChain, the fastest growing Bitcoin network.

Whenever the media talks about Bitcoin they are always referring to it as a currency. “Look at the price!” they say, “Is Bitcoin like gold!?” they shout.

Well, I’m here to tell you that they have completely misrepresented why Bitcoin is so exciting.

Bitcoin is so exciting because it’s underlying technology can be used to build innovative applications.

The number of amazing applications that can be built using Bitcoin technology is so large in fact, we haven’t even thought of all the possibilities yet.

“That makes no sense!” you might think, “How can money be programmed!?”.

In its simplest form, Bitcoin is built on top of a revolutionary technology called the block chain, which is a distributed public ledger that is used to keep track of transactions and store data. The block chain enables decentralized applications to be built in the financial services industry for the first time .

“Awesome Matt, so where do I start? How do I make a Bitcoin application?”

Great question!

Let’s make our first Bitcoin application.

Today we’re going to start easy, you know, just to get our toes wet.

This tutorial will walk you through:

  1. Building a basic Bitcoin tip button that will allow people to click a button on your site and send you Bitcoin by copying the address or using a QR code.
  2. The Coinbase API, which we will be using to power this application and communicate with the block chain using their PHP library.

Ready? Let’s do this.

1. Download the Coinbase PHP Library

To get started we first need to download the Coinbase PHP Library. This is what is going to enable us to develop with the Bitcoin block chain.

Download the Coinbase PHP Library here.

2. Download the PHP QR Code Library.

This is going to allow us to generate QR codes for the Bitcoin address you want people to tip.

Download the PHP QR Code Library here.

3. Copy / Paste the PHP Libraries to where you are developing this app.

Now that we have the two libraries, move their folders into the folder you are developing this app in.

The directory structure should look something like this:

4. Make sure you have the PHP GD library installed.

Login to your server using Terminal or SSH and enter this:

If you’re on Debian or Ubuntu: apt-get install php5-gd

If you’re on RedHate: yum install php55-gd

5. Create a new API key on your Coinbase account.

You’re going to need a Coinbase account for this part, so if you don’t have one already then click here and sign up.

Once you have created an account, go to “Settings” and then go to “API Access”. When creating the new API Key only give the key the “addresses” permission on your primary wallet.

6. Drop our application code into your index.php file.

This is the PHP code you will be using to create the tipping application!

What is it doing exactly?

This code gets your current address from Coinbase and then checks to see if you have a balance on it. If you have no balance, the tip button will direct the tips there. If there is a balance, then the tip button will create a new address in your Coinbase account and send the tip to that new one.

$coinbase = Coinbase::withApiKey($COINBASE_API_KEY, $COINBASE_API_SECRET);
$current_address = $coinbase->getReceiveAddress();
$currentbalance = $coinbase->getBalance($current_address);
if ($currentbalance > 0) { # get a new address $tip_address = $coinbase->generateReceiveAddress();
} else { $tip_address = $current_address;
$qrcode = base64_encode( ob_get_contents() );
<script type=”text/javascript”>
function display_codes() {
var qrcode_html = ‘<?php echo ‘<img src=”data:image/png;base64,’.$qrcode.’\” width=150 height=150>’;?>’;
var address_html = ‘Thanks for your tip! You can send Bitcoins to the following address: <?php echo $tip_address;?>’;
document.getElementById(‘address’).innerHTML = address_html;
document.getElementById(‘qrcode’).innerHTML = qrcode_html;
<button onclick=”display_codes()”>Tip me with Coinbase!</button>
<div id=”address”></div><br>
<div id=”qrcode”></div>

This is what your app should look like:


You just made your very first Bitcoin application!

See, it wasn’t that hard. Now all you have to do is learn more about Coinbase’s API and you will be innovating in no time.

We can’t wait to see what amazing things you create.

Want to learn even more about Bitcoin and start networking with other awesome Bitcoin people? Sign up for ZapChain.

Click “Recommend” below to help spread this tutorial to more people.

Like what you read? Give Matt Schlicht a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.