Book Image

Hands-On Bitcoin Programming with Python

By : BignumWorks Software LLP
Book Image

Hands-On Bitcoin Programming with Python

By: BignumWorks Software LLP

Overview of this book

Bitcoin is a cryptocurrency that’s changing the face of online payments. Hands-On Bitcoin Programming with Python teaches you to build software applications for mining and creating Bitcoins using Python. This book starts with the basics of both Bitcoin and blockchain and gives you an overview of these inherent concepts by showing you how to build Bitcoin-driven applications with Python. Packed with clear instructions and practical examples, you will learn to understand simple Python coding examples that work with this cryptocurrency. By the end of the book, you’ll be able to mine Bitcoins, accept Bitcoin payments on the app, and work with the basics of blockchain technology to create simply distributed ledgers.
Table of Contents (6 chapters)

Installing the Blockchain.info Python library

The following are the steps to install the blockchain Python library:

  1. Open the command-line program on your computer.
  2. Run the pip install blockchain command to install the blockchain library.

The following screenshot shows the installation of bitcoin:

Getting bitcoin exchange rates from Blockchain.info

The following steps shows the method for bitcoin exchange rates:

  1. First, import the exchangerates classes from the blockchain library:
#!/usr/bin/env python

# import blockchain library
from blockchain import exchangerates
  1. Exchange rates define a get_ticker method, which returns the exchange rates data in a dictionary object. Call this method and save the resulting object. The...