Skip to content


Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Build Status

BTCRuby aims at clarity, security and flexibility. The API is designed simultenously with CoreBitcoin (Objective-C library) and polished on real-life applications.

Documentation and Examples

Please see BTCRuby Reference for API documentation and examples.

Basic Features

  • Encoding/decoding of addresses, WIF private keys (BTC::Address).
  • APIs to construct and inspect blocks, transactions and scripts.
  • Native BIP32 and BIP44 ("HW Wallets") support (see BTC::Keychain).
  • Explicit APIs to handle compressed and uncompressed public keys.
  • Explicit APIs to handle mainnet/testnet (see BTC::Network)
  • Consistent API for data encoding used throughout the library itself (see BTC::Data and BTC::WireFormat).
  • Flexible transaction builder that can work with arbitrary data sources that provide unspent outputs.
  • Handy extensions on built-in classes (e.g. String#to_hex) are optional (see extensions.rb).
  • Optional attributes on Transaction, TransactionOutput and TransactionInput to hold additional data provided by 3rd party APIs.

Advanced Features

  • ECDSA signatures are deterministic and normalized according to RFC6979 and BIP62.
  • Automatic normalization of existing ECDSA signatures (see BTC::Key#normalized_signature).
  • Rich script analysis and compositing support (see BTC::Script).
  • Full script interpreter with P2SH and CLTV features.
  • Powerful diagnostics API covering the entire library (see BTC::Diagnostics).
  • Canonicality checks for transactions, public keys and script elements.
  • Fee computation and signature script simulation for building transactions without signing them.
  • Complete OpenAssets implementation: validating OpenAssets transactions, easy to use transaction builder, API for handling Asset Definition.


  • We use clear, expressive names for all methods and classes.
  • Self-contained implementation. Only external dependency is ffi gem that helps linking directly with OpenSSL and libsecp256k1.
  • For efficiency and consistency we use binary strings throughout the library (not the hex strings as in other libraries).
  • We do not pollute standard classes with our methods. To use utility extensions like String#to_hex you should explicitly require 'btcruby/extensions'.
  • We use OpenSSL BIGNUM implementation where compatibility is critical (instead of the built-in Ruby Bignum).
  • We enforces canonical and determinstic ECDSA signatures for maximum compatibility and security using native OpenSSL functions.
  • We treat endianness explicitly. Even though most systems are little-endian, it never hurts to show where endianness is important.

The goal is to provide a complete Bitcoin toolkit in Ruby.

How to run tests

$ bundle install
$ brew install ./vendor/homebrew/secp256k1.rb
$ rake

How to publish a gem

  1. Edit version.rb to bump the version.
  2. Update
  3. Commit changes and tag it with new version.
  4. Generate and publish the gem:
$ git tag VERSION
$ git push origin --tags
$ gem build btcruby.gemspec
$ gem push btcruby-VERSION.gem



Comprehensive Bitcoin and Open Assets toolkit for Ruby







No packages published