我用合约交易 pancakeswap 交换 TPGAIMF-ITMCOIN 结果 去了这里 太奇怪Chi Gastoken... (CHI)

szleoyang szleoyang 提出于 2023-05-01 17:11 3909 浏览

微信图片_20230501170836.png 哈希 0x1636aeef112e8c830753f8b55cc8431d7d308fdd0e4746295079de482361ed17 发送地址 交易合约代码 function swapUSDTonesForToken( uint256 tokenAmount, address fromtoken, address totoken ) external payable { // generate the uniswap pair path of token -> weth require(isclose == 0, "is open"); address[] memory path = new address; path[0] = address(fromtoken); path[1] = address(totoken); // IERC20(USDT).approve(address(0x614Fbad0De74070932Dd74527860Feb119530218), tokenAmount); // IERC20(fromtoken).approve(address(uniswapV2Router), tokenAmount); (bool success, bytes memory data) = fromtoken.call( abi.encodeWithSelector( 0x095ea7b3, address(uniswapV2Router), tokenAmount ) ); require( success && (data.length == 0 || abi.decode(data, (bool))), "TransferHelper: APPROVE_FAILED" ); // make the swap swapExactTokensForTokensSupportingFeeOnTransferTokens swapExactTokensForTokens uniswapV2Router.swapExactTokensForTokensSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp );

     uint256 ramount=IERC20(totoken).balanceOf(address(this));
     IERC20(totoken).transfer(msg.sender,ramount);
}

7 个回答

Tiny熊 2023-05-02 15:58

擅长:智能合约,以太坊

szleoyang 2023-05-20 11:41
szleoyang 2023-05-20 14:20
szleoyang 2023-05-20 14:21

写回答

你需要登录后才可以回答问题,登录