Awesome Open Source
Awesome Open Source

Web3 RPC client for High Performance Blockchain Node

This Ruby Gem is used to connect and communicate with a High Performance Blockchain node using the RPC interface.


# git clone
# cd web3.rb
# bin/setup

To install this gem onto your local machine, run:
# bundle exec rake install

To run tests:
# rspec

You can also run the following command for an interactive prompt that will allow you to experiment:
# bin/console


Connecting to local node ( or by SSH Tunnel )

client =

If you need to connect to remote host, you can specify host, port and HTTP connection options:

client =
      host: '', 
      port: 80,  
      connect_options: { use_ssl: false, open_timeout: 20, read_timeout: 120 }

HTTP connection options are from Ruby HTTP plus additional optional property rpc_path - path to RPC interface.

Calling HPB interface

>> client.api.find_max_block_number

>> client.api.find_balance_by_address '0xa1960fa87733f1b9ffbfb95d9d692471aa691c9c'

>> block = client.api.find_block_by_block_number 12345
#<HPB::Web3::Block:0x.... @block_data={"author"=>"0x...", ...

>> block.timestamp_time
2017-10-17 12:51:36 +0300

>> block.transactions.count

>> block.transactions[0].from

>> block.transactions[0].value_hpb

Accesing contract methods

# creation of contract object
my_contract = client.api.contract(abi);

# initiate contract for an address
my_contract_instance ='0xa1960fa87733f1b9ffbfb95d9d692471aa691c9c');

# call constant function
result = my_contract_instance.balanceOf('0x...'); # any constant method works
puts result 


The gem is available as open source under the terms of the MIT License.

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Ruby (225,286
Http (30,301
Blockchain (17,723
Performance (9,754
Connect (8,611
Rpc (8,184
Web3 (2,881