智能合约接收ERC20代币失败

interface IERC20 {
    function transfer(address recipient, uint256 amount) external;
    function balanceOf(address account) external view returns (uint256);
    function transferFrom(address sender, address recipient, uint256 amount) external ;
    function decimals() external view returns (uint8);
    function approve(address spender, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
}

contract  MyContract {
    IERC20 JY;
    constructor(IERC20 _jy) public  {
        JY = _jy;   
    }
    function approve(uint256 _amount)external{
        JY.approve(address(this),_amount);
    }
    function transferF(uint _amount) external {
        JY.transferFrom(msg.sender,address(this), _amount);
    }
}

授权之后接收代币总是失败

请先 登录 后评论

最佳答案 2021-06-08 15:38

已解决。授权需要在web3.js那边实现

请先 登录 后评论

其它 0 个回答

  • 1 关注
  • 0 收藏,2459 浏览
  • FTTT 提出于 2021-06-07 17:27