Created
October 6, 2021 15:43
-
-
Save sepisoltani/883d638a3bde231f3a7687aeddf0e869 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract Example{ | |
function sayHiToVitalik(string memory _name) public returns (string memory) { | |
// Compares if _name equals "Vitalik". Throws an error and exits if not true. | |
// (Side note: Solidity doesn't have native string comparison, so we | |
// compare their keccak256 hashes to see if the strings are equal) | |
require(keccak256(abi.encodePacked(_name)) == keccak256(abi.encodePacked("Vitalik"))); | |
// If it's true, proceed with the function: | |
return "Hi!"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment