首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >__ERC20Permit_init是什么?

__ERC20Permit_init是什么?
EN

Ethereum用户
提问于 2022-11-15 15:33:30
回答 1查看 87关注 0票数 0

我在查看一些代码时偶然发现了__ERC20Permit_init。这是什么目的?我在谷歌上搜索,并在Initializable.sol of Oppenzeppelin的合同中找到了它。但在不同的合同中使用的是合同中的示例代码。我审查过的代码在一份合同中使用。有什么不同吗?

项目的代码片段

代码语言:javascript
复制
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);
    }
}
EN

回答 1

Ethereum用户

发布于 2022-11-15 18:21:13

我在/contracts/token/ERC20/extensions/ERC20Permit.sol下的ERC20Permit.sol文件中找到了这个

代码语言:javascript
复制
* @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合同上的一个备用函数,您可以通过签名消息来更改它,而不是发送事务。

票数 0
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/139448

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档