Hi @Gaurav_Sahoo,
The solution code is correct for Solidity v0.7. Notice…
pragma solidity 0.7.5;
// but you are using a Solidity v0.8 compiler...
pragma solidity 0.8.7;
The course is based on Solidity v0.7, which was the latest version when it was recorded. Out of the syntax changes introduced with Solidity v0.8, the only one that affects this 101 course is the fact that msg.sender
is no longer a payable address by default…
In Solidity v0.7, msg.sender
is a payable address type by default, and so there is no need to explicitly convert it whenever we need it to be payable, e.g. in selfdestruct() . However, in Solidity v0.8, msg.sender
is now non-payable by default, so you would have to explicity convert it by making the following modification to the code …
address payable receiver = payable(msg.sender);
selfdestruct(receiver);
But instead of converting msg.sender
to a payable address via a separate variable, we can perform the conversion within the selfdestruct() function call itself…
selfdestruct(payable(msg.sender));
You should now be able to complete the assignment and post your contracts here.
But do let me know if anything is still unclear, or if you have any further questions