Technical IconTechnical

This is a complete technical guide to bitcoin.

Each page contains simple text explanations and diagrams for how the different parts of bitcoin work. They also include real-world examples and tools to help you work with raw data in bitcoin.

So if you really want to know how bitcoin works under the hood, this guide is for you.

How to become a bitcoin programmer

I've included lots of code examples within this technical guide to help you with writing your own scripts.

This is because the best way to learn how to become a bitcoin developer is to actually write code.

Code examples are in these boxes

Ruby Icon

Most of the code examples are in Ruby because I think it's the easiest language to read.

If you're not using Ruby, you should be able to use the code snippets as a reference for rewriting the code in the programming language of your choice.

You can read about how bitcoin works as much as you want, but until you start coding, making mistakes (which you will), and building some useful tools, you're never going to make progress. So don't be afraid to give it a go. We've all got to start somewhere.

And if I can learn how to make stuff with bitcoin, so can you.

Anyway, there's no single "best" way to get started with working on bitcoin, but if you're completely new and have no idea where to start, this is what I would recommend…

Install Linux (optional)

This is completely optional, but I'd recommend installing Linux.

I really like Linux for programming work. Linux gives you complete control over your system, and it feels like a natural environment for writing your own programs and tools, because nothing is hidden away from you for your own safety or convenience.

I switched to Linux over a decade ago, and I haven't looked back since – it felt like I gained freedom over my operating system and I've never wanted to go back.

Obviously, if you're proficient with your current development environment, stick with that. But if you want to get better at programming and have felt limited in some way up until now, try using Linux instead.

Install Bitcoin Core

Bitcoin Logo

If you're going to be working with bitcoin, it's a good idea to install Bitcoin Core (the original bitcoin program).

There are a few benefits to running your own local bitcoin node:

Depending on what kind of work you're doing with bitcoin, you may or may not need to run your own full Bitcoin Core node. But if you're not sure, it's good to have it there anyway.

You can list all of the available commands by running bitcoin-cli help.

Use your favourite programming language

Python Icon Ruby Icon Javascript Icon Golang Icon C++ Icon PHP Icon

You can work with bitcoin in any programming language you like, so you might as well use your favourite.

You're more likely to succeed if you work with a programming language that you enjoy, rather than forcing yourself to try to code in a language that you think you "should" be using for some reason.

And if you don't know any languages yet, pick the one that you think looks cool.

Worse comes to worst, if it turns out the language you've chosen is too slow or completely inadequate for some reason, you can always rewrite your project in a different language later on. But you won't know until you try. And rewriting will be much easier the second time around, because you'll already have a library of code to work from.

So don't stress about which programming language to use. Just pick one and go for it. Some popular choices include:

If you want to become a Bitcoin Core developer, you're going to need to learn C++.

I'm a big fan of PHP and Ruby. PHP because it's the language I'm most proficient with (it's what this website and my personal bitcoin library is coded in), and Ruby because it's enjoyable to use and easy to read (it's what most of the examples on this website are written in).

That's not to say you should use these particular languages. In fact, I'd probably get laughed out of some programming circles for using PHP and Ruby (and rightfully so). But they work well for me, and I've created some really useful tools with them, and that's all that matters.

So who's laughing now.

In short, don't get hung up on which language is "best" for bitcoin. The best language is always going to be the one that you can use to actually build stuff with.

There's going to be more help available if you stick to a fairly popular language. If you use a language that nobody else is using, you're going to find that you'll be on your own a lot when it comes to solving tricky problems.

Where to start with bitcoin programming

If I had to provide you with a specific route to take, I'd say these are the three most practical (and satisfying) milestones when learning how to program with bitcoin:

  1. Generating your own keys. This is the perfect place to start. Try generating your own private key, public key, and address. Then import the private key in to a wallet, and see if you get the same address as the one you generated.
    private key: 983836cca5abca95b2d7c1c1d83957c3a1f64049f1dec71c14e686ccdeaab208
    public key:  0366d16f9e942cda437e40ee7711ea219be281beb2aeefb8a97d2f0032388ce72f
    address:     12vgEcTgX4AZwkV7sgbECLk222h3nBBDwp  
  2. Decoding a transaction. Learning how to decode a raw transaction will teach you a lot about the structure of a bitcoin transaction, and they make up 99% of the data inside the blockchain.
    Transaction Splitter
  3. Creating your own transaction. After decoding a transaction, you're all set to create your own. This is a much bigger milestone (so take your time), but it's the natural next step. Signing it will be the tricky part, but if you can successfully send your own bitcoin transaction in to the network, then you can safely say that you're a pretty good bitcoin programmer.
    Transaction Builder

And if you can create you own bitcoin transactions, there's nothing else in bitcoin that will be outside your ability.

Write command line tools

Screencast showing bitcoin command line tools being used in the terminal.

Writing command-line tools is a good way to get started with programming for bitcoin.

This is especially true if you don't have an idea for a project yet. Plus, if you're going to be spending any time working with bitcoin data, it's always going to be handy to have a bunch of command-line utilities to help you along the way.

Some basic command line tools that will prove to be very useful over the long run are:

But don't get bogged down by writing command line tools for the sake of it. It's a good way to get started, but your main focus on your journey to becoming a bitcoin programmer should be working on your own projects…

Your first bitcoin project (important)

The best way to learn to become a bitcoin programmer is to try and build something.

If you've got an idea for something you want to build, just go for it and learn what you need to learn as you go. You don't need to know about every aspect of bitcoin to start making something useful.

It may seem like an intimidating task at the start, especially if you're new to bitcoin and/or programming, but if you just take it one step at a time you'll get there eventually.

Because as with anything in life, it's impossible to fail if you refuse to give up.

Anyway, I'm guessing you've already got an idea of what you want to build. But if you need some inspiration, here are some popular tools that other people have built:

Web Tools

Desktop Tools

Command Line Tools

This is just a handful of cool tools that I know have been made by individuals. I think they're good inspiration for what can be done with bitcoin if you have a good idea and the determination to see it through.

So just go ahead and create something useful that doesn't already exist, then make it available for other people to use, and see what happens.

Be responsible. You need to be very careful if you're creating a tool that handles private keys or creates transactions for other people (e.g. a wallet). It's one thing to make your own mistakes and lose your own coins, but it's another to make mistakes that cause other people to lose coins, so don't take it lightly.

Share your work on GitHub. This is a good way to share your code with the world, and it's also a good way to display your experience if you're looking to get a job (if that's the direction you want to go in).

Summary

Don't let anyone make you think that you can't be a bitcoin programmer.

Bitcoin is decentralized, open-source software. You can generate your own keys and construct your own transactions if you want to, and nobody can stop you. That's part of what makes bitcoin, bitcoin.

I'm sure some people will want to convince you that you need some kind of qualification to work with bitcoin, but allow me to tell you, you don't. Everything you need can be learnt for free on the Internet, or even by just looking at the bitcoin source code. The only real qualification you need to work on bitcoin is the desire to contribute, and everything else can be learnt along the way.

We've all got to start somewhere, and if you've got an idea and the passion to make it happen, then you're just as qualified to become a bitcoin programmer as anyone else.

The best wallets and tools were built by people that, at some point, had no prior experience with bitcoin.

Other Resources

Nobody learns about an entire subject from just a single book or website any more, so here are some other excellent technical resources for bitcoin that I've found useful:

Websites

Books

Other

Libraries

A smart way to learn how bitcoin works is to learn from existing bitcoin libraries written in the language you're using yourself.

You can find a bitcoin library in pretty much any programming language by searching for "[language] bitcoin library". For example:

There's a wealth of open-source code out there, and sometimes it's best to see how someone else has solved a problem to help you figure out how to do it yourself.

Good luck.