我在查看一些代码时偶然发现了__ERC20Permit_init。这是什么目的?我在谷歌上搜索,并在Initializable.sol of Oppenzeppelin的合同中找到了它。但在不同的合同中使用的是合同中的示例代码。我审查过的代码在一份合同中使用。有什么不同吗?
项目的代码片段
contract LPToken is ILPTokenInit, ILiquidStakingManagerChildContract, Initializable, ERC20PermitUpgradeable {
//...
constructor() initializer {}
function init(
address _deployer,
address _transferHookProcessor,
string calldata _tokenSymbol,
string calldata _tokenName
) external override initializer {
deployer = _deployer;
transferHookProcessor = ITransferHookProcessor(_transferHookProcessor);
__ERC20_init(_tokenName, _tokenSymbol);
__ERC20Permit_init(_tokenName);
}
}发布于 2022-11-15 18:21:13
我在/contracts/token/ERC20/extensions/ERC20Permit.sol下的ERC20Permit.sol文件中找到了这个
* @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.因此,它似乎启用了ERC20合同上的一个备用函数,您可以通过签名消息来更改它,而不是发送事务。
https://ethereum.stackexchange.com/questions/139448
复制相似问题