// version of solidity greater than 5
pragma solidity ^0.5.10;

// write a contract using contract keyword
contract HelloWorld {
    // data type string
    string myName = 'Ryan';

    // write a function that returns name
    function getMyName() public view returns(string memory) {
        return myName;
    }

    // writable function, arguments are prefixed with _
    function changeMyName(string memory _newName) public {
        myName = _newName;
    }
}
  • Now compile then deploy.
  • On the deployed contract, you see changeMyName button with input field.
  • Enter new name and click on changeMyName button
  • Then if you click getMyName button, you will see the new name returned