Switch API

This was originally a question regarding Switch API setup, but because in the mean time I solved it, I thought I would turn this post into something useful for the community. - a few tips:

  • credentials in small caps - at least ETH

  • when it runs it creates a config file in home/user/.switch. If run multiple times with same credentials (tests), this file has to be deleted first

  • in some cases, the response from the network regarding the validated ledger might take a little bit to arrive. In this case, a tx request would not receive the correct answer; work around is to introduce a delay for the tx request, as in here.
    This has to be done also on the reference connector side, in the @kava xrp-plugin.

  • below is the config of the reference ilp connector to connect to Switch Api, in case @kava connector-config is not used. While for the given use case it wasn’t needed, in a real scenario, for “outgoingChannelAmount”, “minIncomingChannelAmount”, “maxPacketAmount”, you may still want to use a conversion as in @kava’s original connector-config.

      const { convert, usd, gwei } = require('@kava-labs/crypto-rate-utils')
      const axios = require('axios')
      //to get gas price
      const getGasPrice = async () => {
        const { data } = await axios.get(
          'https://ethgasstation.info/json/ethgasAPI.json'
        )
    
        return convert(gwei(data.fast / 10), wei())
      } 
    
      const peerETH = {
            relation: 'child',
            plugin: 'ilp-plugin-ethereum',
            assetCode: 'ETH',
            assetScale: 9,
            options: {
                role: 'server',
                port: 7442, 
                ethereumPrivateKey: '0x43c50a578883922df30a33eb74418fb568c0081c40256e4675df02dcc28b6ef6', 
                ethereumProvider: 'http://192.168.1.87:8545', //using Ganache
                getGasPrice: getGasPrice, 
                outgoingChannelAmount: '71440000',       //10 usd
                minIncomingChannelAmount: '3570000',  // 0.5usd
                // In plugin (and not connector middleware) so F08s occur before T04s
                maxPacketAmount: '1430000'    // 0.2USD 
            }
      }
2 Likes

Hey @Lucian_Trestioreanu!

Thanks again for test driving it!

Some updates based on your feedback:

  • Fingers crossed, we fixed the issue you experienced with the XRP NotFoundError in v0.4.3+ of @kava-labs/ilp-plugin-xrp-paychan and v0.4.7+ of @kava-labs/switch-api
  • Added a note to the README in ilp-sdk (renamed switch-api) explaining the config file and where it’s located :+1:

Hi, @Kincaid! :slight_smile: Thank you very much for your hints towards unblocking the issue, and for this quick update! Congrats Kava for Switch API!

Hi, @Kincaid!

ILP-SDK can at this point swap currencies for same user, is this correct?
How about using it to send ETH from user A towards user B XRP wallet?

i.e., instead entering user A private key ETH (sending wallet) + user A private key XRP (receiving wallet),
to fill in: user A private key ETH (sending wallet) + user B XRP address (receiving wallet)?

Generally, does anybody know if there is any working app (way) able to send XRP from User A’s XRP wallet towards User B’s ETH wallet right now?

Thank you very much