我正在学习solidity,在写完这个合约,编译报错TypeError: Contract "ERC20" should be marked as abstract.请问要如何修改

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

//IERC20的标准只包括接口
//只要满足IERC20的接口,合约对外包含IERC20所列出的所有的接口-->满足IERC20的标准
//只要合约中实现了IERC20接口中所列出的所有方法 --->满足
//合约逻辑怎样实现是没有强制要求的
 interface  IERC20{
    //代表者当前合约的toukan总量
    function totalSupply() external view returns (uint);

    //代表着某一个账户的当前余额
    function balanceOf(address account) external view returns (uint);
    //transfer方法:把账户中的余额由当前调用者发送到另一个账户中
    //写入方法-->会向链外汇报一个标准的transfer事件
    //通过transfer事件就可以查询touken 的流转
    function transfer(address recipient,uint amount) external returns (bool);
    //
    function allowance(address owner ,address spender) external view returns (uint);
    //approve方法:是一个批准。代表着把我账户中的数量批准给另一个账户
    //通过allowance方法可以查询某一个账户对另一账户的批准额度有多少
    function approve(address spender,uint amount) external returns (bool);
    //向另一合约存款时必须要调用transferFrom方法才能把我们账户中的touken拿到合约中
    function transferFrom(address sender,address recipient,uint amount) external returns (bool);

    event Transfer(address indexed  from,address indexed  to,uint amount);
    event Approval(address indexed  owner,address indexed  spender,uint amount);
}

//继承 
contract  ERC20 is  IERC20{
    //定义数字变量:用于标明当前合约的touken总量
    uint public totalSupply;
    //定义映射
    mapping (address =>uint) public balanceOf;//一个地址对应一个数字就可以组成一个账本  IERC20的核心
    mapping (address =>mapping (address => uint))public allowance;//批准的映射
    string public name = "Test";//touken的名字
    string public symbol = "TEST";//touken的符号
    uint8 public decimals = 18;//touken的精度

//发送方法的基本逻辑:在发送者账户中减掉一个数量,在接收者的账户中增加一个数量
//要操作的变量:balanceOf的映射--->核心账本
    function transfer(address recipient, uint amount)external returns (bool){
        balanceOf[msg.sender] -= amount;
        balanceOf[recipient] += amount;
        emit Transfer(msg.sender, recipient, amount);//触发transfer事件
        return  true;
    }
//批准方法的基本逻辑:修改批准映射
//在批准映射中,首先找到当前合约的调用者
    function approve(address spender,uint amount ) external returns (bool){
        allowance[msg.sender][spender] = amount;//spender被授权账户
        emit  Approval(msg.sender, spender, amount);//触发批准额度的事件
        return  true;
    }
    //这个函数的调用者对应的就是批准额度中的被批准的账户,发送者对应的就是批准额度中的调用者
    function tranferFrom(address sender,address recipient,uint amount)external returns (bool){
        allowance[sender][msg.sender] -= amount;
         balanceOf[sender] -= amount;
         balanceOf[recipient] += amount;
         emit Transfer(sender, recipient, amount);
         return true; 
    }
}
TypeError: Contract "ERC20" should be marked as abstract. --> contracts/ERC20.sol:32:1: 32 contract ERC20 is IERC20{ ^ (Relevant source part starts here and spans across multiple lines). Note: Missing implementation: --> contracts/ERC20.sol:25:5:
25 function transferFrom(address sender,address recipient,uint amount) external returns (bool);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
请先 登录 后评论

1 个回答

Tiny熊
  擅长:智能合约,以太坊
请先 登录 后评论
  • 2 关注
  • 0 收藏,851 浏览
  • 提出于 2024-07-23 16:10