50 币安测试链调用薄饼换币合约失败(合约里充有wp代币,薄饼的测试流动池也添加上了这两个交易对)

pragma solidity 0.6.6;
import "https://github.com/Uniswap/v2-periphery/blob/master/contracts/UniswapV2Router01.sol";
contract owned {
    address public owner;

    constructor () public{
        owner = msg.sender;
    }
    modifier onlyOwner {
        require (msg.sender == owner);
        _;
    }
}
interface TetherToken {
    function balanceOf(address who) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function transfer(address to, uint256 value) external returns (bool);
    function transferFrom(address _from, address _to, uint256 _value) external returns (bool);
}

contract Bhe is owned{
    address router_address = 0xD99D1c33F9fC3444f8101754aBC46c52416550D1 ;
    UniswapV2Router01 public uniswapRouter;
    address wp = 0x22bd6B32F007410A78B2F31AF1a59eE74193956c;
    address dog = 0x5257C1F1804605218b4b46851F5488bf278524F2;
    TetherToken public c_wp = TetherToken(wp);  //U
    constructor() public{
        uniswapRouter = UniswapV2Router01(0xD99D1c33F9fC3444f8101754aBC46c52416550D1);
    }
    function inside(uint _usdt) public returns(uint[] memory){
        uint deadline = block.timestamp + 15;
        c_wp.approve(router_address, _usdt);
        return uniswapRouter.swapExactTokensForTokens(_usdt, 0, getPath(),address(this),deadline);  
    }
    function getPath() private view returns (address[] memory) {
        address[] memory path = new address[](2);
        path[0] = wp;
        path[1] = dog;
        return path;
    } 
}
请先 登录 后评论

最佳答案 2022-01-30 22:34

测试router 0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3

请先 登录 后评论

其它 0 个回答

  • 1 关注
  • 0 收藏,3632 浏览
  • wupeng 提出于 2022-01-30 18:44