I'm new to blockchain and I'm following a tutorial. However, I'm getting problem compiling my first contract on Truffle.
Here's my code :
pragma solidity ^ 0.5.2;
contract ApprovalContract
{
address public sender;
address public receiver;
address public constant approver = 0x6af7A9CFe4D4B938Ff4038Fd0625d18C5D671834;
function deposit(address payable _receiver) external payable{
require(msg.value>0);
sender = msg.sender;
receiver = _receiver;
}
function viewApprover() external pure returns(address)
{
return(approver);
}
function approve() external {
require(msg.sender == approver);
receiver.transfer(address(this).balance);
}
}
Now while I try to compile my code through the terminal, this is the error I get.
SyntaxError: Source file requires different compiler version (current compiler is 0.5.0+commit.1d4f565a.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version pragma solidity ^ 0.5.2; ^----------------------^ ,/C/Users/neonalliance/Desktop/Solidity/contracts/ApprovalContract.sol:22:3: TypeError: Member "transfer" not found or not visible after argument-dependent lookup in address. receiver.transfer(address(this).balance); ^---------------^
Error: Truffle is currently using solc 0.5.0, but one or more of your contracts specify "pragma solidity ^ 0.5.2". Please update your truffle config or pragma statement(s). (See https://truffleframework.com/docs/truffle/reference/configuration#compiler-configuration for information on configuring Truffle to use a specific solc compiler version.)
I think the problem is due to some update or modifications in Solidity as the tutorial I am following is of 2017, but I cannot exactly figure out what I need to do.
So what could possible be the solution ?
Note: Since this is my first Blockchain Learning phase, I request you to please answer in a way I could possibly grasp the information.