Getting error while accessing bitcoin client from ruby using Rpc I am getting the following error while trying RPC call from ruby. bitcoind server is running. I am using bitcoin-ruby library .

Code Tried in irb to test:

require 'bitcoin'
=&gt; true
irb(main):002:0&gt; txid= "611b40973fe68cc42b70ae5af365a449af458d76086415c6fa6c45364c36278e"
=&gt; "611b40973fe68cc42b70ae5af365a449af458d76086415c6fa6c45364c36278e"
irb(main):003:0&gt; rtx= bitcoinRPC('getrawtransaction',[txid])


Error :

NoMethodError: undefined method `bitcoinRPC' for main:Object
    from (irb):3
    from /usr/bin/irb:11:in `&lt;main&gt;'


Any suggetion will be highly appreciated.

Thanks in advance,

R
Use the following method to call BitcoinRPC using Ruby:

Create ruby file test.rb as

require 'net/http'
require 'uri'
require 'json'

class BitcoinRPC
  def initialize(service_url)
    @uri = URI.parse(service_url)
  end

  def method_missing(name, *args)
    post_body = { 'method' =&gt; name, 'params' =&gt; args, 'id' =&gt; 'jsonrpc' }.to_json
    resp = JSON.parse( http_post_request(post_body) )
    raise JSONRPCError, resp['error'] if resp['error']
    resp['result']
  end

  def http_post_request(post_body)
    http    = Net::HTTP.new(@uri.host, @uri.port)
    request = Net::HTTP::Post.new(@uri.request_uri)
    request.basic_auth @uri.user, @uri.password
    request.content_type = 'application/json'
    request.body = post_body
    http.request(request).body
  end

  class JSONRPCError &lt; RuntimeError; end
end

if $0 == __FILE__
  h = BitcoinRPC.new('http://username:password@127.0.0.1:8332')
  txid= "611b40973fe68cc42b70ae5af365a449af458d76086415c6fa6c45364c36278e"
  p h.getrawtransaction(txid)
end


NOTE: 
username and password are from your bitcoin.conf file.