I am writing a program in Python using the web3 library, which needs to make several translations in a single transaction. Here is an example. But I didn't find anything about it in the documentation. Some examples do several transactions through a loop, but it doesn't suit me at all.
Asked
Active
Viewed 641 times
2 Answers
1
You have only two ways for this.
- You need build your own contract, that do all this transactions by one contract call.
- You need use multicall -- this is special contract, exists at every network. You send you transaction to multicall contract and run all by one call.

lesnik
- 76
- 2
0
Creating a smart contract is the only way to do it.
something like this:
function multiSwap(uint256 deadline, uint256 amountOutMinUniswap) external payable {
uint256 amountOutMinBancor = 1;
uint256 amountOutMinSushiSwap = 1;
_tradeOnBancor(msg.value, amountOutMinBancor);
_tradeOnSushi(IERC20(BNT).balanceOf(address(this)), amountOutMinSushiSwap, deadline);
_tradeOnUniswap(IERC20(INJ).balanceOf(address(this)), amountOutMinUniswap, deadline);
}
Check out a great article by Markus Waas - Making multiple swaps

derevo
- 9,048
- 2
- 22
- 19