调用薄饼合约换币失败

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;
    } 
}
请先 登录 后评论

1 个回答

Tiny熊
  擅长:智能合约,以太坊
请先 登录 后评论
  • 1 关注
  • 0 收藏,2976 浏览
  • wupeng 提出于 2022-01-30 18:32