Bitcoin Script: a Reading List
While thinking about and implementing BitAuth2017, I compiled a list of articles and resources about Bitcoin Script — the scripting…
While thinking about and implementing BitAuth2017, I compiled a list of articles and resources about Bitcoin Script — the scripting language which is used in Bitcoin to define and satisfy various transaction authentication requirements.
Here’s a short reading list of the articles and resources I find myself referencing repeatedly. I hope others will find it useful too.
Getting Started
- Mastering Bitcoin by Andreas M. Antonopoulos – Chapter 5, Transactions: This chapter is worth reading in it’s entirety. It’s an excellent primer, and uses (in my opinion) the clearest language and terminology.
- Bitcoin Developer Guide: Standard Transactions: The Bitcoin Developer Guide contains a fantastic overview of the entire Bitcoin system.
- Bitcoin Wiki: Script: The Bitcoin Wiki contains hundreds of pages of excellent technical information and discussion. If you have a question, it’s likely been asked, answered, and explained in detail on the wiki.
Diving Deeper
- The Bitcoin Script language: Part of Davide De Rosa’s Basic Blockchain Programming blog series — one of the best guides I’ve ever seen on the details of Bitcoin. I find myself referring to this series again and again. (It’s a technical reference in it’s own right.)
- A look at Bitcoin non-standard outputs: A short but interesting examination of different types of non-standard outputs collected by parsing the bitcoin blockchain.
- Bitcoin Contracts: This article will show you just how deep the rabbit hole goes. Includes a demonstration of Escrow, “Kickstarter” transactions, and a full, decentralized lottery.
P2SH
- BIP 16: Pay to Script Hash: P2SH is almost a separate topic on it’s own, and can take some experimentation to understand fully. BIP 16 is the standard which defines the P2SH transaction type, and is a great place to start.
- Bitcoin multisig the hard way: Understanding raw P2SH multisig transactions: If you’re having trouble understanding exactly how P2SH multisig works, this article is perfect. It walks through every detail with a full example.
Read the Code
- Bitcoin Core Reference Implementation: The Bitcoin Script implementation in Bitcoin Core is surprisingly easy to read. If you’re really having trouble answering a specific question, you might find that reading the code is the fastest (and most definitive) way to answer it.
Script Testing Environments
These can be hard to find, and are the original reason I compiled this list.
There’s definitely an opportunity here for a well-designed, well-maintained, open source project for writing and debugging Bitcoin Script.
The following projects provide some pretty solid options, in various states of repair, and in no particular order. (I usually need to flip between several before I find one that seems to handle a given input in a helpful way.)
- Bitcoin Script Execution Debugger: This one isn’t particularly intuitive, but it’s extremely utilitarian. The clear Execution Trace section makes this one my favorite.
- Hashmal: Might be the best right now, but requires installing software locally (written in python).
- BitcoinIDE: Web based, and provides an excellent stack visualization.
- Bitcoin Script Explorer: Promising — a little confusing to use, but includes some great examples.
- Script Playground: No frills, but simple to use. Also seems very reliable.
Note: Always test on Testnet before using real money. Many sad stories begin with someone creating a custom raw bitcoin transaction.
Looking to the Future
- BIP 141: If the Segregated Witness soft fork happens, there are some new and interesting changes in store for Bitcoin Script, including Bitcoin Script language versioning and reduced limitations on script sizes.
Have something I should add to this list? Please leave a comment or send me a note!