简体   繁体   English

通过合约发送代币

[英]send token by contract

i have a question down.addressA approve to contract B 100 busd allownce already.我有一个问题。addressA 已经批准合同 B 100 busd allownce。 how can i transfer 1 busd to owner address of contract.我怎样才能将 1 busd 转移到合同的所有者地址。 here is the code.这是代码。

pragma solidity ^0.8;

interface IERC20  {
    function totalSupply() external view returns (uint256);

    function balanceOf(address account) external view returns (uint256);

    function transfer(address recipient, uint256 amount)
        external
        returns (bool);

    function allowance(address owner, address spender)
        external
        view
        returns (uint256);

    function approve(address spender, uint256 amount) external returns (bool);

    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(
        address indexed owner,
        address indexed spender,
        uint256 value
    );
}
contract BigContract {
    address owner = 0xFAD69bCefb704c1803A9Bf8f04BC314E78838F88;
    //address public sender;

    function withdrawToken(address tokenContract,  uint256 amount) external {
        // send `amount` of tokens
        // from the balance of this contract
        // to the `owner` address
        IERC20(tokenContract).transfer(owner, amount);
    }
    function sendToken(address tokenContract, address sender ,uint256 amount) external {
       
        IERC20(tokenContract).transferFrom(
         sender,
         owner,
         amount
    );
    }
}

address sender appoved 100 busd to the Bigcontract owner address of contract call the function sendToken return gas fee 0.65BNB thank you very much.地址发件人批准了 100 总线到 Bigcontract 所有者的合同地址,请致电 function sendToken 返还汽油费 0.65BNB 非常感谢。

how to make this call working?如何使这个电话工作?

The sender has to approve BigContract , not owner . sender必须批准BigContract ,而不是owner

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM