尝试使用REMIX IDE创建我的第一个智能合约,但是遇到了声明错误。这是我合同的代码
/****代码开始**/
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.2;
import "./Context.sol";
import "./IBEP20.sol";
import "./SafeMath.sol";
import "./Ownable.sol";
contract SampleTaken is Context, IBEP20, Ownable {
mapping(address => unit) public balances;
unit public totalSupply = 1000000 * 10 ** 18;
String public name ="Sample Token";
String public symbol ="KJA";
unit public decimals = 18;
/** Events aailable for the Contract**/
event Transfer(address indexed _from, address indexed _to, uint256 _value);
constructor(){
balances[msg.sender] = totalSupply;
}
function balanceOf(address _ownerAddress) public view returns (unit){
return balances[_ownerAddress];
}
function transfer(address _toAddress, unit _noOfTokens) public view returns (bool){
require(balanceOf(msg.sender) >= _noOfTokens, "Total balance is less than the number of Tokens asked for !!!");
balances[_toAddress] +=_noOfTokens;
balances[msg.sender] -= _noOfTokens;
emit Transfer(msg.sender,_toAddress, _noOfTokens);
return true;
}
function transferFrom(address _from, address _to, uint _value) public returns (bool){
require(balanceOf(_from) >= _value, "Balance is less than the number of Tokens asked for !!!");
require(allowance[_from][msg.sender] >= _value, "Allowance too low");
balances[_to] += _value;
balances[_from] -= _value;
emit Transfer (_from, _to, _value);
return true;
}
}在尝试编译它时,我得到了以下错误
DeclarationError: Identifier not found or not unique. --> SampleToken.sol:13:24: | 13 | mapping(address => unit) public balances; | ^^^^这里可能遗漏了什么?
谢谢,山姆
发布于 2021-05-10 15:54:25
该错误是由代码中的拼写错误引起的。
它应该是uint (无符号整数)-而不是unit。
https://stackoverflow.com/questions/67465114
复制相似问题