Welcome to the extensive guide to Bitcoin Javascript! In this guide we will explain how to create various types of Bitcoin transactions, using the BitcoinJS library.
We will use the Bitcoin Core command-line interface in Regtest mode for various common tasks, as well as some
complementary libraries like bx
aka Libbitcoin Explorer.
Throughout this guide, we want to provide you with sufficient explanation to each command to understand it without drowning in information. You can refer to additional resources to better understand the Bitcoin protocol. For example, check out our Bitcoin Studio presentations.
At the moment, Bitcoin Javascript tutorials are still very scarce, but we believe it doesn't have to be this way. The following guide intends to address this problem.
Having prior theoretical knowledge of the Bitcoin protocol will surely help, but we provide comprehensive explanation throughout this guide so it fits for beginners.
Technical requirements
- Node v10.x or superior
- BitcoinJS v4.x or superior
- Bitcoin Core v17.x or superior
- Libbitcoin Explorer v3.4.x or superior
Unless otherwise noted, the contents of this repository are Copyright ©2018 by Bitcoin Studio and are licensed CC-BY.
- This guide is not an official documentation
- You must check the BitcoinJS repository for up-to-date code
- Non-standard scripts are exposed for educational purposes
- The author of this guide is not responsible for any loss of funds
PART ONE: PREPARING THE WORK ENVIRONMENT
- 1.0: Introduction to Bitcoin Programming with BitcoinJS and Bitcoin Core
- 2.0: Generating and Importing Wallets
PART TWO: PAY TO PUBLIC KEY HASH
- 3.0: Legacy P2PKH
- 3.1: Simple Transaction (1 input, 1 output) - Legacy P2PKH
- 3.2: Typical Transaction (1 input, 2 outputs) - Legacy P2PKH
- 3.3: UTXO Consolidation (5 inputs, 1 output) - Legacy P2PKH
- 3.4: Batching Transaction (1 input, 5 outputs) - Legacy P2PKH
- 3.5: Coinjoin Transaction (4 inputs, 4 outputs) - Legacy P2PKH
- 4.0: Native Segwit P2WPKH
- 5.0: Spend a Embedded Segwit P2SH-P2WPKH UTXO
- 6.0: Embedding Data With OP_RETURN
PART THREE: PAY TO SCRIPT HASH
- 7.0: Bitcoin Script Puzzles or Pay to Script Hash
- 8.0: Multi-signature Transactions
- 9.0: Timelock Transactions
Please consider making a donation so that I can continue producing free educational content
Donate with Bitcoin | 3CmJsUcx6txveq32kVqG92pczc1suLh6BD