I am trying to understand how to handle the encoding and decoding of the abi library provided by solidity.
I have tried to encode a message and then decode it. But it always gives me error. I have removed one of the parameters that were in string because maybe it had to be encoded to bytes too. But using the address type also fails me.
Where am I going wrong?
contract EncodeDecode {
function encode(address account, uint number) public pure returns(bytes memory) {
return abi.encodePacked(account, number);
}
function decode(bytes memory data) public pure returns(address, uint) {
(address account, uint number ) = abi.decode(data, (address, uint));
return (account, number);
}
}