自己写的合约里面调用USDT泰达币合约

先从etherscan上copy了泰达USDT的合约本地部署,地址是0xd9145CCE52D386f254917e481eB44e9943F39138,再部署了一个自己写的合约,地址是:0xd8b934580fcE35a11B58C6D73aDeE468a2833fa8 构造函数填上了之前泰达的地址,代码如下:

`// SPDX-License-Identifier: MIT pragma solidity 0.8.9;

interface USDT{

function balanceOf(address account) external view returns(uint256);
function approve(address spender, uint256 amount) external returns(bool);
function transfer(address to, uint256 amount) external returns(bool);
function transferFrom(address from, address to, uint256 amount) external returns(bool);
function allowance(address owner, address spender) external view returns (uint);

}

contract SwapCenter{ USDT _usdt;

    constructor(address usdt) {
        _usdt=USDT(usdt);
    }

function balanceOf(address account) external view returns(uint256){
    return _usdt.balanceOf(account);
}

function approve(address spender, uint256 amount) external returns(bool){
    return _usdt.approve(spender, amount);

}

function transfer(address to, uint256 amount) external returns(bool){
    return _usdt.transfer(to,amount);
}

function transferFrom(address from, address to, uint256 amount) external returns(bool){
    return _usdt.transferFrom(from, to, amount);
}

 function allowance(address owner, address spender) external view returns (uint){
     return _usdt.allowance(owner,spender);
 }

}`

首先用USDT合约的transfer给我自己写的合约地址转币了,我的理解那就是我写的合约有币了,在调用我自己合约写的transfer,就可以实现对某个地址转币。因为合约地址本身有币了,且去到USDT的合约里她相当于msg.sender,但是一直报错:Note: The called function should be payable if you send value and the value you send should be less than your current balance.

求大神解答

请先 登录 后评论

最佳答案 2023-06-29 01:13

USDT并非标准的ERC20代币。

请先 登录 后评论

其它 3 个回答

LS
请先 登录 后评论
LS
请先 登录 后评论
LS
请先 登录 后评论
  • 2 关注
  • 0 收藏,2644 浏览
  • LS 提出于 2023-06-28 23:27