Compiler errors 智能合约代码中预期的未识别错误-混音

Compiler errors 智能合约代码中预期的未识别错误-混音,compiler-errors,solidity,remix,Compiler Errors,Solidity,Remix,编译器报告下面附加的错误;很奇怪,我正在跟随课程的导师,导师建议我使用旧版本的混音,我在类似的问题中读到“returns”应该是单数,但他的代码编译没有问题,我还是尝试了,没有成功;他正在使用^0.4.11我正在运行^0.8.4,尽管当我降级到以前的版本时问题仍然存在 错误: ParseError: Expected '{' but got 'constant' --> tests/pendulum_ico.sol:28:60: | 28 | function equity_in_pen

编译器报告下面附加的错误;很奇怪,我正在跟随课程的导师,导师建议我使用旧版本的混音,我在类似的问题中读到“returns”应该是单数,但他的代码编译没有问题,我还是尝试了,没有成功;他正在使用^0.4.11我正在运行^0.8.4,尽管当我降级到以前的版本时问题仍然存在

错误:

ParseError: Expected '{' but
got 'constant' -->
tests/pendulum_ico.sol:28:60: |
28 | function 
equity_in_pendulum(address 
investor) external constant 
returns (uint) { | ^^^^^^^^
pragma solidity ^0.8.3;

contract pendulum_ico {
    
// Introducing the maximum number of Pendulum available for sale

    uint public max_pendulum = 1000000;
    
// Introducing the USD to Pendulum conversion relocatable

    uint public usd_to_pendulum = 1000;
    
// Introducing the total number of Pendulum that have been bought by the investors

    uint public total_pendulum_bought = 0;
    
// Mapping from the investor address to its equity in Pendulum and usd_to_pendulum

    mapping(address => uint) equity_pendulum;
    mapping(address => uint) equity_usd;
    
// Checking if an investor can buy Pendulum

    modifier can_buy_pendulum(uint usd_invested) {
        require (usd_invested * usd_to_pendulum + total_pendulum_bought <= max_pendulum);
        _;
    }
    
// Getting the equity in Pendulum of an investor

    function equity_in_pendulum(address investor) external constant returns (uint) { 
        return equity_pendulum[investor];
    }                             
    
// Getting the equity in USD of an investor

    function equity_in_usd(address investor) external constant returns (uint) {
        return equity_usd[investor];
    }
    
// Buying Pendulum 

    function buy_pendulum(address investor, uint usd_invested) external
    can_buy_pendulum(usd_invested) {
        uint pendulum_bought = usd_invested * usd_to_pendulum;
        equity_pendulum[investor] += pendulum_bought;
        equity_usd[investor] = equity_pendulum[investor] / 1000;
        total_pendulum_bought += hadcoins_bought;
        
    }
    
// Selling Pendulum 

    function sell_pendulum(address investor, uint pendulum_sold) external {
        equity_pendulum[investor] -= pendulum_sold;
        equity_usd[investor] = equity_pendulum[investor] / 1000;
        total_pendulum_bought -= pendulum_sold;
    }
    
}
代码:

ParseError: Expected '{' but
got 'constant' -->
tests/pendulum_ico.sol:28:60: |
28 | function 
equity_in_pendulum(address 
investor) external constant 
returns (uint) { | ^^^^^^^^
pragma solidity ^0.8.3;

contract pendulum_ico {
    
// Introducing the maximum number of Pendulum available for sale

    uint public max_pendulum = 1000000;
    
// Introducing the USD to Pendulum conversion relocatable

    uint public usd_to_pendulum = 1000;
    
// Introducing the total number of Pendulum that have been bought by the investors

    uint public total_pendulum_bought = 0;
    
// Mapping from the investor address to its equity in Pendulum and usd_to_pendulum

    mapping(address => uint) equity_pendulum;
    mapping(address => uint) equity_usd;
    
// Checking if an investor can buy Pendulum

    modifier can_buy_pendulum(uint usd_invested) {
        require (usd_invested * usd_to_pendulum + total_pendulum_bought <= max_pendulum);
        _;
    }
    
// Getting the equity in Pendulum of an investor

    function equity_in_pendulum(address investor) external constant returns (uint) { 
        return equity_pendulum[investor];
    }                             
    
// Getting the equity in USD of an investor

    function equity_in_usd(address investor) external constant returns (uint) {
        return equity_usd[investor];
    }
    
// Buying Pendulum 

    function buy_pendulum(address investor, uint usd_invested) external
    can_buy_pendulum(usd_invested) {
        uint pendulum_bought = usd_invested * usd_to_pendulum;
        equity_pendulum[investor] += pendulum_bought;
        equity_usd[investor] = equity_pendulum[investor] / 1000;
        total_pendulum_bought += hadcoins_bought;
        
    }
    
// Selling Pendulum 

    function sell_pendulum(address investor, uint pendulum_sold) external {
        equity_pendulum[investor] -= pendulum_sold;
        equity_usd[investor] = equity_pendulum[investor] / 1000;
        total_pendulum_bought -= pendulum_sold;
    }
    
}
pragma-solidity^0.8.3;
合同钟摆{
//介绍可供销售的摆锤的最大数量
uint公共最大摆锤=1000000;
//引入美元到钟摆转换可重新定位
uint公共美元对美元=1000;
//介绍投资者购买的钟摆总数量
uint公共总购买量=0;
//从投资者地址到其在钟摆和美元对钟摆中的权益的映射
映射(地址=>uint)权益;
映射(地址=>uint)权益单位美元;
//检查投资者是否可以购买钟摆
修改器可购买摆锤(单位投资美元){
要求(从0.4 a到0.5 a之间购买的美元投资*美元对钟摆+总钟摆:

现在不允许使用
常量
作为函数状态可变修饰符


在0.8中,还可以将函数声明为,它符合0.4
常量中定义的状态不变性标准

function equity_in_pendulum(address investor) external view returns (uint) { 
    return equity_pendulum[investor];
}

彼得,你不知道自己帮了多少忙。