Last active
March 22, 2019 21:50
-
-
Save YazzyYaz/09db32822c6a617e0c809035c17b1cbc 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
| pragma solidity 0.5.1; | |
| contract TrademarkRegistration { | |
| struct TradeMark { | |
| string phrase; | |
| string authorName; | |
| uint256 timestamp; | |
| bytes32 proof; | |
| } | |
| mapping (bytes32 => bool) private trademarkLookup; | |
| mapping (bytes32 => TradeMark) public trademarkRegistry; | |
| function checkTradeMark(string memory phrase) public view returns (bool) { | |
| bytes32 proof = phraseProof(phrase); | |
| return trademarkLookup[proof]; | |
| } | |
| function registerTradeMark(string memory document, string memory author) public returns (bool){ | |
| if (checkTradeMark(document) == false) { | |
| bytes32 proofHash = phraseProof(document); | |
| TradeMark memory trademark = TradeMark({ | |
| phrase: document, | |
| authorName: author, | |
| timestamp: now, | |
| proof: proofHash | |
| }); | |
| trademarkLookup[proofHash] = true; | |
| trademarkRegistry[proofHash] = trademark; | |
| return true; | |
| } | |
| return false; | |
| } | |
| function phraseProof(string memory phrase) public view returns (bytes32) { | |
| return sha256(abi.encode(phrase)); | |
| } | |
| function getTradeMarkData(string memory phrase) | |
| public view returns | |
| (string memory document, | |
| string memory authorName, | |
| uint256 timestamp, | |
| bytes32 proof) { | |
| TradeMark memory t = trademarkRegistry[phraseProof(phrase)]; | |
| return (t.phrase, t.authorName, t.timestamp, t.proof); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment