An open API service indexing awesome lists of open source software.

https://github.com/fukaoi/crystal-ripple

Ripple blockchain client sdk for crystal
https://github.com/fukaoi/crystal-ripple

blockchain crystal crystal-language ripple sdk

Last synced: 12 days ago
JSON representation

Ripple blockchain client sdk for crystal

Awesome Lists containing this project

README

        

# crystal-ripple-sdk
[![Build Status](https://travis-ci.org/solidum-particles/crystal-ripple-sdk.svg?branch=master)](https://travis-ci.org/solidum-particles/crystal-ripple-sdk)

Client SDK for a rippled, Can doing about creates accounts, setting multisig, sends payment.
this SDK dependency is [ripple-lib](https://github.com/ripple/ripple-lib), [crystal-nodejs](https://github.com/fukaoi/crystal-nodejs). And no need to install Node.JS, ripple-lib of the npm module, Because of the function of crystal-nodejs. If you want to know crystal-nodejs, read README of crystal-nodejs

The main function as Account, Multisig, Payment has existed, there always run verify function after submit the transaction on ripple network . So is the finallize response that return value of crystal-ripple-sdk

## Installation

1. Add the dependency to your `shard.yml`:

```yaml
dependencies:
ripple:
github: solidum-particles/crystal-ripple-sdk
```

2. Run `shards install`

## NPM module installation

want to add npm module

1. Add the npm module to `js/package.json`

2. Run `make && make install`

## Audit NPM mobule and JS code

Scan npm module for vulnerability and Perform static analyze of js code for security

1. Run `make secure_check`

## Usage

### Account

#### Set up network(testnet or mainnet)

Only once call set_network() in an application

```crystal
Ripple.set_network(Ripple::Network::Testnet)

or

Ripple.set_network(Ripple::Network::Mainnet)
```

Connect to rippled URL("s.altnet.rippletest.net:51233" or "s1.ripple.com:443")in default, But want to change URL

```crystal
Ripple.set_network(Ripple::Network::Testnet, "wss://xxxxxxxxxxxxxxxxxxx")

or

Ripple.set_network(Ripple::Network::Mainnet, "wss://xxxxxxxxxxxxxxxxxxx")
```

#### Generate an account for mainnet

```crystal
require "ripple"

Ripple.set_network(Ripple::Network::Mainnet)
Ripple::Account.generate_account

#
```

#### Generate an account for testnet

Can receive payment 1000 XRP from testnet faucet when a created account

```crystal
require "ripple"

Ripple.set_network(Ripple::Network::Testnet)
Ripple::Account.generate_account

#
```

#### Get account info by address

```crystal
require "ripple"

Ripple::Account.get_info("rfu3t8HwXARgwKHBKmi5QANw4ta8khwbMY")

#
```

### Multisig

#### Create signer list

```crystal
require "ripple"

owner_account =
{
address: "rKN412L8bRyG3t6Gb3KasggrjdxgtAcU9g",
secret: "shqf5DBf41QE1b3eeBU11KFizVsb4",
}

signers =
[
{
address: "r9VQQuGXQRLsQ6CUG2jmwPDr9cGyeczUiY",
weight: 2,
},
{
address: "r3bJteyQ9VU6gQPn5Ar6nMH9ELjUTY12f",
weight: 1,
},
]

quorum = 3

Ripple::Multisig.create_signer_list(
owner_account,
signers,
quorum
)

# source: src/ripple/js_class/*

* Ripple::JsClass::Account
* Ripple::JsClass::Multisig
* Ripple::JsClass::Payment

#### Response types

Be Converted to Ripple::Response class from all responses of ripple-lib

>source: src/ripple/response/*

* Ripple::Response::Account
* Ripple::Response::Memos
* Ripple::Response::Multisig
* Ripple::Response::Payment
* Ripple::Response::Settings
* Ripple::Response::Verify

#### Error types

>source: src/ripple.cr

ResponseError

* Raised exception, If the empty response from ripple-lib

ValidationError

* Raised this exception in two cases, one it when is returned key "validError" in JS code, two it when did validation error in Crystal code

#### Create address in command line

a wordy command, but you can write with one liner.Changing Mainnet and Testnet is
only change of param(Ripple::Network) in set_network() method

* testnet:

```crystal
crystal eval 'require "./src/ripple";Ripple.set_network(Ripple::Network::Testnet);p Ripple::Account.generate_account'
```

* mainnet:

```crystal
crystal eval 'require "./src/ripple";Ripple.set_network(Ripple::Network::Mainnet);p Ripple::Account.generate_account'
```

## Contributing

1. Fork it ()
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request

## Contributors

- [fukaoi](https://github.com/fukaoi) - creator and maintainer