// using BSC Testnet β ETH Rinkeby for this example
val crossChain = sdk.bscTestnetEthRinkebyClient
val credentials = Credentials.createFromKeyPhrase("A mnemonic phrase goes here")
?: error("Invalid mnemonic phrase")
val token1 = sdk.bscTestnet.token.CAKE
val token2 = sdk.ethRinkeby.token.UNI
val trade = crossChain.findBestTradeExactIn(
// a number of CAKE tokens to spend
amountIn = token2.convertRealToInteger(1.bn)
) ?: error("Trade was not found")
// Calculated amount of UNI tokens to receive
val amountOutNum = trade.convertIntegerToReal(trade.finalAmountOut)
println("Estimated amountOut: $amountOutNum}")
// Sending the cross-chain swap transaction
val transaction = crossChain.execute(credentials, trade)
val log = transaction.waitForComplete()
val success = when (log) {
// Waiting for the transaction processing on the origin blockchain
// and an event on the destination blockchain
Transaction hash on BSCT: ${transaction.hash}
Transaction hash on Rinkeby: ${log.transactionHash}
Transaction status: ${if (success) "Success" else "Failure" }