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 } }