bitcoin-client Build Status Coverage Status

Provides a Ruby library to the complete Bitcoin JSON-RPC API. Implements all methods listed at Also supports customizing the host and port number to connect to.


On Ruby 1.9, you can just install the gem and start using it. On 1.8, the 'json' gem is also required, so you'll need to install that first:

gem install json

Or, if you're using Bundler (and you should be), just add it to the Gemfile:

gem 'json', '~> 1.5.3'


As with most Ruby gems, you first need to require the library into your project:

require 'bitcoin'

After doing this, the simplest possible usage looks like this:

Bitcoin('username', 'password').balance
# => 0.001

Or, if you prefer a somewhat more explicit representation, the following code performs the exact same task:

client ='username', 'password')
# => 0.001

The third and final way to use the library is by taking advantage of a simple DSL:

include Bitcoin

# set up credentials
username 'username'
password 'password'

# => 0.001

# => {"account" => 0.001}

The RPC method names available to you are exactly the same as those listed on the Bitcoin wiki (again, that's Some aliases have been added to make them more “ruby-ish,” but none of the original names have been changed.

Host, Port and SSL

Here are several examples of how you can change the host information:

Bitcoin('username', 'password', :host => '', :port => 38332, :ssl => true)

client ='username', 'password', :host => '')
client.port = 38332
client.ssl = true
# => true

include Bitcoin
host ''
port 38332
# => false
ssl true
# => true

You should see the Bitcoin::Client class documentation if you'd like to see the other options and methods that are made available.


If you found this library useful and feel inclined to compensate me for my trouble, I'm certainly not going to turn you down!

Bitcoin donations can be sent to: