赞
踩
uniswap 官方接口文档:https://uniswap.org/docs/v2/smart-contracts/router02/#interface
测试地址:0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.2; // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.2; // helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false library TransferHelper { function safeApprove(address token, address to, uint value) internal { // bytes4(keccak256(bytes('approve(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED'); } function safeTransfer(address token, address to, uint value) internal { // bytes4(keccak256(bytes('transfer(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED'); } function safeTransferFrom(address token, address from, address to, uint value) internal { // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED'); } function safeTransferETH(address to, uint value) internal { (bool success,) = to.call{ value:value}(new bytes(0)); require(success, 'TransferHelper: ET
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。