ABI Encode
When transpiling solidity code which uses ABI encoding, cairo functions are generated to mimic this behaviour. These functions return a felt array where each element is between 0 and 255, a representation of Solidity's bytes array.
ABI Encoding and Packed Encoding on both solidity and warped contracts will be similar except for addresses. Due to cairo addresses being able to occupy the whole felt space and solidity's being only 160 bits (considerably smaller) it creates compatibility issues, such as:
When ABI Encoding: although each data type occupies 32 bytes slot, and a
felt
fits perfectly inside, an address encoded on a warped contract on Starknet and later decoded on a L1 will cause arevert
if the address is bigger than 20 bytes. If you wish to decode a cairo address on L1 you must substitute the address type foruint256
(or other similar size type) e.gabi.decode(data, (address))
->abi.decode(data, (uint256))
When ABI Packed Encoding: instead of storing the cairo address inside 20 bytes and having a potential information lost, they are stored as 32 bytes. As a consequence, the packed encoding in a warped contract and the solidity contract will always differ if addresses are one of the included types.