From the course: Building an Ethereum Blockchain App: 7 Smart Contracts

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Solidity data modifiers, part 2

Solidity data modifiers, part 2

- Okay, so now we're back in VS Code. We're looking at our data type .sol smart contract, and I've added a little bit to it. So you'll notice there's a new function at the very bottom. We did have a function, getStateVariables, this is a public function, and we see that from the public keyword right here. So what this does is it does several things, the public keyword, and by the way, there's another keyword, another modifier we haven't talked about view. View tells us, or tells the compiler, actually, that the body of my function will only reference local variables, in other words, I'm not touchin the blockchain. We do that to save costs, we save gas and we also can do that to help the compiler keep us honest because now if I go into my function and I try to write code that interacts with the blockchain, the compiler is going to say, "Nope, not going to let it happen," and gives me a nasty error message, not a warning, but…

Contents