https://github.com/interledgerjs/ilp-protocol-spsp
SPSP client for ILPv4
https://github.com/interledgerjs/ilp-protocol-spsp
Last synced: about 1 year ago
JSON representation
SPSP client for ILPv4
- Host: GitHub
- URL: https://github.com/interledgerjs/ilp-protocol-spsp
- Owner: interledgerjs
- Created: 2018-01-14T05:39:04.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-06-10T18:35:07.000Z (about 7 years ago)
- Last Synced: 2025-03-30T23:31:34.574Z (about 1 year ago)
- Language: JavaScript
- Size: 41 KB
- Stars: 6
- Watchers: 5
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ILP Protocol SPSP
## Description
Implements version 4 of the [Simple Payment Setup Protocol](https://github.com/interledger/rfcs/pull/447).
## Example
### Simple Usage
Sends a single-chunk PSK payment or a STREAM payment, if the server supports
it. Great for micro-payments or micro-donations inside of a script.
```js
try {
const resp = await SPSP.pay(plugin, {
pointer: '$bob.example.com',
sourceAmount: '1000'
})
console.log(`sent "${resp.totalSent}"`)
} catch (e) {
console.log(`sent "${e instanceof SPSP.PaymentError ? e.totalSent : 0}"`)
}
```
Make a pull payment from a designated pull payment pointer.
```js
try {
const resp = await SPSP.pull(plugin, {
pointer: '$bob.example.com/4139fb24-3ab6-4ea1-a6de-e8d761ff7569',
amount: '1000'
})
console.log(`pulled "${resp.totalReceived}"`)
} catch (e) {
console.log(`pulled "${e instanceof SPSP.PaymentError ? e.totalReceived : 0}"`)
}
```
### Advanced Usage
Query the endpoint manually to construct a STREAM or PSK2 payment.
```js
const query = await SPSP.query('$bob.example.com')
console.log(query)
// {
// destination_account: "test.example.bob.LwNAw4ZEjlOwkc8xmaQRaRd37YRl8sixSCBPgEEqo8I",
// shared_secret: "RvqL/HJO3GinYIeujez/OEsBtX6+NtxJwabh7KthfOI=",
// content_type: "application/spsp4+json"
// }
```
The query may contain additional information.