Smart contracts function execution - Flash swap

I’ve been interested in smart contracts and there is one thing I can not understand at all.


  • in Java/Kotlin using web3j
  • using Infura’s API for ITX transactions

In this smart contract there is a function called swap:

    // this low-level function should be called from a contract which performs important safety checks
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external lock {

Now what I’m wondering is, how do these functions work?
I read about flash swaps but I do not understand them in this case and something about callbacks, but that I would assume stands for JS callbacks.

If I want to swap token A for token B, what all do i have to do to submit a transaction to Infura?

Thank you very much.

1 Like