Last active
February 28, 2017 10:07
-
-
Save peculiarity/e61c1645c7ef47a04ebfc69fea5d635c to your computer and use it in GitHub Desktop.
This file contains 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
const contract = fileSystem.readFileSync("./contract.sol").toString("utf-8"); | |
console.log(contract); | |
// output | |
contract StringContainer { | |
string[] public listOfStrings; | |
StringUtils utils = new StringUtils(); | |
function add(string memory newString) returns (bool success){ | |
for(uint index=0;index<listOfStrings.length;index++) { | |
if(utils.equals(listOfStrings[index], newString)){ | |
return false; | |
} | |
} | |
listOfStrings.push(newString); | |
return true; | |
} | |
} | |
contract StringUtils { | |
function equals(string memory first,string memory second) constant returns (bool areEqual){ | |
bytes memory bytesFirst = bytes(first); | |
bytes memory bytesSecond = bytes(second); | |
if(bytesFirst.length != bytesSecond.length){ | |
return false; | |
} else { | |
for (uint i = 0; i < bytesFirst.length; i++) | |
if (bytesFirst[i] != bytesSecond[i]) | |
return false; | |
} | |
return true; | |
} | |
} | |
Example app listening on port 3000! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment