First of all your code has so many typos. In the constructor, there should be ==
not a single one and then its msg.sender
not msg . sender
.
Your code should look like this:
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.1;
contract Discontinue {
address payable owner ;
constructor () {
owner == msg.sender ;
}
function Terminate (address payable addr) public {
if ( msg.sender == owner ){
selfdestruct (addr);
}
}
}
Now, this compiled successfully for me. Another thing is,
You are using a very old compiler which is full of bugs in Remix.
I prefer the ^0.7.x
version. Or If you want only ^0.5.1
I would advise you to code on VS Code, Maybe you will not get these errors there.
Hope this will help you :)
(Edit)
Actually, if I try to compile this code with 0.5.1
It tells me to put contructors' visibility, when I put public
with the constructor, it gives me another error saying, public
should not be there.
And one thing more if I comment out the constructor and add the owner hardcoded like this address payable owner = msg.sender ;
it compiles successfully.
// SPDX-License-Identifier: MIT
pragma solidity ^0.5.1;
contract Discontinue {
address payable owner = msg.sender ;
// constructor public () {
// owner == msg.sender ;
// }
function Terminate (address payable addr) public {
if ( msg.sender == owner ){
selfdestruct (addr);
}
}
}
This compiled successfully.