DEV Community

Cover image for Pure Functions in Solidity - The Basics
Abraham covenant
Abraham covenant

Posted on

Pure Functions in Solidity - The Basics


Today I will be giving you some information that you will find useful , as regards solidity pure functions , let's dive straight into it.

What are solidity pure functions?

In simple terms a solidity pure function is a function that doesn't read or modify the variables of the state of the contract, It can only use local variables that are declared in the function and the arguments that are passed to the function as function parameters, You can also use the keyword ‘Pure’ to make a pure function.

What you shouldn’t Do With Pure Functions

  • Read a state variable

  • Call other functions not declared as pure

  • Modify the state of the contract

What you should do if you get this warning

Image description

Now there’s no cause for alarm , this is only trying to tell you that since the function doesn’t modify the contracts state you should make it a pure function ,
To get rid of the warning add a pure keyword to the function , or better still ensure that you use the function to modify the state of the contract.

I hope this helps, i am Abraham Covenant a fullstack developer steadily acquiring more knowledge as regards my development endeavors, i’m proficient in Html , Css , Javascript , Php , React js , Solidity and Css frameworks such as Tailwind Css and Bootstrap.

If you also want a private session with me send me an email

My portfolio

Top comments (0)