Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/you21979/node-ripple-usecase
https://github.com/you21979/node-ripple-usecase
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/you21979/node-ripple-usecase
- Owner: you21979
- License: mit
- Created: 2015-01-14T03:37:47.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-02-06T04:23:24.000Z (almost 10 years ago)
- Last Synced: 2024-04-15T04:27:12.834Z (7 months ago)
- Language: JavaScript
- Size: 223 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ripple-usecase
install
```
npm install ripple-usecase```
## usecase of user watch
```
var rp = require('ripple-lib-promise');
var UserAccount = require('ripple-usecase').UserAccount;
rp.createConnect().then(function(remote){
var u = new UserAccount(remote, 'ripple address');
return u.assets().then(function(res){
res.forEach(function(v){
var l = [v.name];
if(v.account !== ''){
l.push(v.account);
}
console.log("%s,%d", l.join('.'), v.value)
})
})
})
```## usecase of gateway watch
```
var rp = require('ripple-lib-promise');
var GatewayAccount = require('ripple-usecase').GatewayAccount;
rp.createConnect().then(function(remote){
var g = new GatewayAccount(remote, 'tokyojpy', 'r94s8px6kSw1uZ1MV98dhSRTvc6VMPoPcN', 'JPY');
g.debt().then(function(res){
console.log('gateway trust count %d', res.holders.length);
Object.keys(res.debt).forEach(function(key){
console.log('gateway balance %s:%d', key, res.debt[key]);
});
});
})
```## usecase of payment
## usecase of trade
```
var rp = require('ripple-lib-promise');
var TradeWallet = require('ripple-usecase').TradeWallet;
rp.createConnect().then(function(remote){
var w = new TradeWallet(remote, 'your address', 'your secret');
var pair = 'XRP_JPY.r94s8px6kSw1uZ1MV98dhSRTvc6VMPoPcN';
w.orderbook(pair).then(function(book){
// your trade condition
var price = 0.1;
var amount = 100;
var expire = 3600; // option
w.buy(pair, price, amount, expire).then(console.log);
})
})
```