Skip to content

IToT 2 Interledger over BTP

Michiel de Jong edited this page Sep 22, 2017 · 2 revisions

Set up an ILP node on your laptop

  • make sure you have node installed (you can easily install it using http://nvm.sh)
  • In one screen:
$ npm install michielbdejong/ilp-node#62a7979
$ node ./node_modules/ilp-node/src/server-from-config-file
started { btp:
   { listen: 8000,
     name: 'ab833ece33938b2327b0d7ab78a28a39c498c9915e8ab05026d5400f0fa2da34',
     initialBalancePerPeer: 10000,
     upstreams: [] },
  xrp:
   { secret: 'shvKKDpRGMyKMUVn4EyMqCh9BQoP9',
     address: 'rhjRdyVNcaTNLXp3rkK4KtjCdUd9YEgrPs',
     server: 'wss://s.altnet.rippletest.net:51233',
     prefix: 'test.crypto.xrp.' } }

In another:

$ node ./node_modules/ilp-node/scripts/flood.js 10000 btp btp
[ '/Users/michiel/.nvm/versions/node/v7.7.1/bin/node',
  '/Users/michiel/gh/michielbdejong/ilp-node/scripts/flood.js',
  '10000',
  'btp',
  'btp' ]
flooder open, flooding
10000 transfers took 4179ms, that is 2392.916965781287 payments per second.
^C
  • You should see it can do around 3000 payments per second.

What just happened?

  • The command in the first screen starts an Interledger connector. It listens for insecure WebSockets on ws://localhost:8000.
  • The command in the second screen creates an Interledger sender and an Interledger receiver. Both connect to the connector, as WebSocket clients.
  • Then, the receiver queries the connector to find out its Interledger address.
  • The receiver passes its address to the sender, who then sends 10,000 'PREPARE' messages to the connector.
  • The connector recognized the destination address as the receiver's, and forwards the payments by creating another 10,000 prepared transfers.
  • The receiver fulfills its incoming transfers using the fulfillments which it shares with the sender in the script in the second screen.
  • The connector relays these fulfillments back to the sender.

Interledger chaining

What's interesting is to compare one of the connector-to-receiver ("outgoing") transfers to the sender-to-connector ("incoming") transfer which it corresponds to; together, the two ledger transfers form one interledger payment:

  • it will have the same executionCondition (so that a fulfillment for the outgoing transfer will always be useful as the fulfillment of, also, the incoming transfer)
  • it will have an amount that is worth at most as much as the incoming transfer's amount (otherwise the connector loses money in the deal)
  • its timeout will be a little bit before the incoming transfer's timeout (so that the connector still has time to fulfill the incoming transfer if the outgoing transfer is fulfilled just-in-time)

Next

This little example showed an Interledger payment that stays within your laptop. In the next tutorial, we'll make one that goes over the XRP ledger.