[英]Multiple transfers within one transaction?
I am writing a program in Python using the web3 library, which needs to make several translations in a single transaction.我正在使用 web3 库在 Python 中编写一个程序,该程序需要在单个事务中进行多次翻译。 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.
一些示例通过循环执行多个事务,但它根本不适合我。
You have only two ways for this.你只有两种方法。
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查看 Markus Waas 的一篇精彩文章 - 进行多次交换
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.