Created
May 2, 2018 04:37
-
-
Save ayinot/e986b3087229c8c4e55178bad5cba9a2 to your computer and use it in GitHub Desktop.
Parsing the TxnInput
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 Parsing { | |
function callNumber(uint256 number) public view returns(bytes32){ | |
bytes32 hash = keccak256("callNumber(uint256)"); | |
return hash; | |
} | |
function callAddress(address _addr) public view returns(bytes32){ | |
bytes32 hash = keccak256("callAddress(address _addr)"); | |
return hash; | |
} | |
function parsing(bytes _txnInput) public view returns(uint) { | |
uint length = _txnInput.length; | |
//pseudocode | |
//1. copy the first 8 bytes in byte array | |
//2. copy the 32 byte which hold the parameter in a byte array (which is hex) | |
//3. convert hex into decimal and get the method parameter | |
// Is this pseudocode right ? | |
// bytes32 result; | |
// uint j=10; | |
// for(uint i=0;i<length-10;i++) { | |
// result[i] = _txnData[j]; | |
// j++; | |
// } | |
// } | |
return length; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment