举几个简单的例子:
比如在ERC20合约里,曾经有过这样的方法:
function approveAndCall(
address _spender,
uint256 _value,
bytes memory _extraData)
public returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, address(this), _extraData);
return true;
}
}
以及ERC1155合约里,有这样的方法:
function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes calldata _data) external
这两个方法中都出现了bytes参数,请问这个参数一般是干嘛用的,以及,如果要用这些接口,但是不需要额外加bytes参数,可否直接传值为0?