[英]Why my code showing pragma error on remix?
I'm practicing with some open codes.我正在练习一些开放代码。 also I'm pretty new on solidity.我对坚固性也很陌生。 When i try to compile my code, it keep getting this Error: browser/grow.sol:1:1: Warning: Source file does not specify required compiler version!当我尝试编译我的代码时,它不断收到此错误: browser/grow.sol:1:1: 警告:源文件未指定所需的编译器版本! Consider adding "pragma solidity ^0.5.0;"考虑添加“pragma solidity ^0.5.0;” ^ . ^ 。 I'm using REMIX & compiler version 0.5.0我正在使用 REMIX 和编译器版本 0.5.0
/**
*Submitted for verification at Etherscan.io on 2020-08-25
*/
pragma solidity ^0.5.0;
contract ERC20Interface {
function totalSupply()
public
view
returns (uint);
function balanceOf(address tokenOwner)
public
view
returns (uint balance);
function allowance
(address tokenOwner, address spender)
public
view
returns (uint remaining);
function transfer(address to, uint tokens) public
returns (bool success);
function approve(address spender, uint tokens) public
returns (bool success);
function transferFrom
(address from, address to, uint tokens) public
returns (bool success);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}
contract SafeMath {
function safeAdd(uint a, uint b) public pure returns (uint c) {
c = a + b;
require(c >= a);
}
function safeSub(uint a, uint b) public pure returns (uint c) {
require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0);
c = a / b;
}
}
contract MYTOKEN is ERC20Interface, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
constructor() public {
name = "MYTOKEN";
symbol = "MYT";
decimals = 18;
_totalSupply = 1000000000000000000000000;
balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function totalSupply() public view returns (uint) {
return _totalSupply - balances[address(0)];
}
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
}
No errors on my side.我这边没有错误。 Have you tried to recompile your code once you've haded the pragma
statement?一旦你有了pragma
语句,你是否尝试过重新编译你的代码? In remix, you can recompile your code in the SOLIDITY COMPILER
section (left side of the screen).在 remix 中,您可以在SOLIDITY COMPILER
部分(屏幕左侧)重新编译您的代码。 Sometimes error stays until code is recompiled.有时错误会一直持续到重新编译代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.