Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/DevNullProd/XRBP
XRP / Ruby Library
https://github.com/DevNullProd/XRBP
blockchain cryptocurrency xrp xrp-ledger
Last synced: about 1 month ago
JSON representation
XRP / Ruby Library
- Host: GitHub
- URL: https://github.com/DevNullProd/XRBP
- Owner: DevNullProd
- License: mit
- Created: 2019-03-27T00:30:32.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-23T20:47:20.000Z (over 4 years ago)
- Last Synced: 2024-08-03T16:09:52.422Z (5 months ago)
- Topics: blockchain, cryptocurrency, xrp, xrp-ledger
- Language: Ruby
- Homepage:
- Size: 309 KB
- Stars: 11
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-xrpl - xrbp - Ruby :: [rubydoc](https://www.rubydoc.info/gems/xrbp) (Libs / Libs / Production-Ready)
README
### XRBP - Ruby XRP Library
XRBP is a rubygem which provides a fault-tolerant interface to the [XRP](https://en.wikipedia.org/wiki/XRP) ledger.
With XRP you can connect to one or more [rippled](https://github.com/ripple/rippled) servers and use them to transparently read and write data to/from the XRP Ledger:
```ruby
require 'xrbp'ws = XRBP::WebSocket::Connection.new "wss://s1.ripple.com:443"
ws.add_plugin :autoconnect, :command_dispatcherws.cmd XRBP::WebSocket::Cmds::ServerInfo.new
```XRBP provides fully-object-oriented mechanisms to interact with the ledger:
```ruby
ws.on :ledger do |l|
puts "Ledger received: "
puts l
endXRBP::Model::Ledger.subscribe(:connection => ws)
```#### Supported Features:
Other data types besides ledgers may be syncronized:
```ruby
puts XRBP::Model::Account.new("rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B").info
```Also data from other sources, such as the [Ripple DataV2 API](https://developers.ripple.com/data-api.html)
```ruby
connection = XRBP::WebClient::Connection.new
XRBP::Model::Validator.all(:connection => connection)
.each do |v|
puts v
end
```XRPB allows easy access to the following data:
- XRP ledgers, transactions, account, and objects
- Network nodes, validators, gateways
- Markets with quotes
- & more (see *examples/* for more use cases)#### Multiple Connections
XRBP facilitates fault-tolerant applications by providing customizable strategies which to leverage multiple rippled servers in communications.
```ruby
ws = XRBP::WebSocket::RoundRobin.new "wss://s1.ripple.com:443",
"wss://s2.ripple.com:443"ws.add_plugin :command_dispatcher
ws.connectputs ws.cmd(XRBP::WebSocket::Cmds::ServerInfo.new)
puts ws.cmd(XRBP::WebSocket::Cmds::ServerInfo.new)
```In this case the first **ServerInfo** command will be sent to *s1.ripple.com* while the second will be sent to *s2.ripple.com*.
The following demonstrates prioritized connections:
```ruby
ws = XRBP::WebSocket::Prioritized.new "wss://s1.ripple.com:443",
"wss://s2.ripple.com:443"ws.add_plugin :command_dispatcher, :result_parser
ws.parse_results { |res|
res["result"]["ledger"]
}
ws.connectputs ws.cmd(XRBP::WebSocket::Cmds::Ledger.new(28327070))
```*s1.ripple.com* will be queried for the specified ledger. If not present *s2.ripple.com* will be queried.
#### Installation / Documentation
XRPB may be installed with the following command:
```ruby
$ gem install xrbp
```Documentation is available [online](https://www.rubydoc.info/gems/xrbp)
#### License
Copyright (C) 2019 Dev Null Productions
Made available under the MIT License