[Ethereum] Decoding contract output of web3 eth call

abicalldataweb3js

I have written data to a contract using sendRawTransaction, and am trying to fetch it using web3.eth.call for the function :
function checkRecord(uint id, bytes email) constant returns (uint id2, bytes email2, bytes hash) {..}

I create call data as
var callData = contract.checkRecord.getData(id, email)
to get
'0xf1e8a43c0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000156d617467656f2e3230303840676d61696c2e636f6d0000000000000000000000'

and fetch result as
result = web3.eth.call({'to': address, 'from': account, 'data': callData})

where result is
'0x0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000156d617467656f2e3230303840676d61696c2e636f6d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000'

How do i decode the result back to (uint, bytes, bytes) ?

Best Answer

you can use web3 built-in functionality:

web3.eth.abi.decodeParameters(typesArray, hexString);

see link