abi.encode
abi.encode
abi.encodeonly deals with 32 byte data
function abiEncode() external {
bytes32 x40;
assembly {
x40 := mload(0x40)
}
emit MemoryPointer(x40);
abi.encode(uint256(5), uint256(19)); // needs to store the length of the data that follows, along with the variables
assembly {
x40 := mload(0x40)
}
emit MemoryPointer(x40); ; // returns 0xe0 instead, which is 32 bytes into the future
}
function abiEncode2() external {
bytes32 x40;
assembly {
x40 := mload(0x40)
}
emit MemoryPointer(x40);
abi.encode(uint256(5), uint128(19));
assembly {
x40 := mload(0x40)
}
emit MemoryPointer(x40); // still returns 0xe0
}abi.encodePacked- will try and make the values as short as possible
Last updated