Skip to content

Instantly share code, notes, and snippets.

@justmoon
Created June 3, 2016 01:27
Show Gist options
  • Save justmoon/4cffdd01fce7f26a68e64e5bab0bb3f3 to your computer and use it in GitHub Desktop.
Save justmoon/4cffdd01fce7f26a68e64e5bab0bb3f3 to your computer and use it in GitHub Desktop.
API for ILP core
import { Client } from 'ilp-core'
const client = new Client({
  auth: {
    account: 'https://far-far-away-ledger.example/accounts/bob',
    password: 'super-secret-password',
  }
})

const payment = client.createPayment({
  destinationAmount: '1',
  // or sourceAmount
  destinationAccount: 'https://red.ilpdemo.org/ledger/accounts/alice',
  destinationLedger: 'https://red.ilpdemo.org/ledger',
  destinationMemo: {
    foo: 'bar'
  },
  sourceMemo: {
    thisWasFor: 'that thing'
  }
})

payment.quote()
  .then((quote) => {
    // quote.sourceAmount (BigNumber)
    // quote.destinationAmount (BigNumber)
    //...
    payment.sendQuoted(quote)
  })

// can be used instead of payment.sendQuoted
payment.send({
  maxSourceAmount: '11',
  maxHoldTime: 10000
})
.then((transfer) => {
  
})
.catch((err) => {
  
})
import { Client } from 'ilp-core'
const client = new Client({
  auth: {
    account: 'https://far-far-away-ledger.example/accounts/bob',
    password: 'super-secret-password',
  }
})

client.on('incoming', (transfer) => {
  
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment