I'm studying Uniswapv2 codes and I got stucked with ABI. https://github.com/Uniswap/v2-core/blob/master/contracts/UniswapV2Pair.sol
- Why use ABI with
call
method, even if we can calltransfer
function from interface directly?
bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
.
.
.
function _safeTransfer(address token, address to, uint value) private {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'UniswapV2: TRANSFER_FAILED');
}
- I've read a lot about ABI, and I'm confused about some says that it is JSON format and some says it is byte form. What is right?