Search code examples
ethereumsoliditysmartcontractsremix

How to add response to HelloWorld in Solidity Remix?


I want to add a response to this Hello World example.

HelloWorld.sol
// SPDX-License-Identifier: MIT
// compiler version must be greater than or equal to 0.8.13 and less than 0.9.0
pragma solidity ^0.8.13;

contract HelloWorld {
    string public greet = "Hello World!";
    string public respond = "Good morning, starshine!"; // trying to add this line
}

When I run the contract in Remix before the line I'm attempting to add, I see this...

enter image description here

What I expect to see after my added line is another button called respond and when I press it, I expect below it to read:

string: Good morning, starshine!

But instead, I see no change than when run without my added line.

How do I achieve the expected behavior?


Solution

  • I see no errors in your code you have to redeploy the contract again by clicking orange Deploy button