0

I'm a very new programmer and have been give a assignment in solidity at remix however I am unable to resolve this error

Warning: Function state mutability can be restricted to pure --> new.sol:27:1: | 27 | function stopVehicle() public view returns( string memory){ | ^ (Relevant source part starts here and spans across multiple lines).

and here is my code


contract ParentVehical{

//start vehicle

function startVehicle() public view returns( string memory){

string memory start = "The vehicle has just started" ;

return (start);

}

//accelerate

function accVehicle() public view returns( string memory){

string memory accelerate = "The Vehicle has just Accelerated" ;

return (accelerate);

}

//stop vehical

function stopVehicle() public view returns( string memory){

string memory stop = "The Vehicle has just Stopped" ;

return (stop);

}

//service vehical

function serviceVehicle() public view returns( string memory){

string memory service = "The Vehicle is being serviced" ;

return (service);

}

}```
0

This is a warning not an error message. So you can continue without any changes.

This message tells you this function is neither reading blockchain nor writing on it, so you don't need to define it as view function. You can define this function as pure function:

function accVehicle() public pure returns(string memory) {
    ...
}
1
  • Thank you so much!
    – Isra Ghous
    Jul 14 '21 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.