You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🧐 Motivation
It is impossible to extend ERC-1155 in a way that the derived contract is accessing the _operatorApprovals, because the mapping is private and there is no internal method to modify it. Thus, only the ERC1155 contract itself can set or unset approvals. This makes extensions like an ERC1155Permit impossible as they need a way to modify the approval mapping. The proposal is to add an internal function, which can be used in contracts extending ERC1155 to modify _operatorApprovals.
📝 Details
Contracts extending ERC1155 need a way to modify _operatorApprovals. There are two options:
Change _operatorApprovals visibility from private to internal
Add an internal function to modify the mapping.
The proposal is for option two as it aligns well with ERC20, which has a similar setup: private _allowances, which can be modfied in derived contracts with _approve(owner, spender, amount).
The function to be added to ERC1155 is this:
function _setApprovalForAll(address owner, address operator, bool approved)
internal virtual {
require(owner != operator, "ERC1155: setting approval status for self");
require(owner != address(0), "ERC1155: approve from the zero address");
require(operator != address(0), "ERC1155: approve to the zero address");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
The main difference to the existing public setApprovalForAll(address operator, bool approved) is that it allows to add approvals for other owners than msg.sender, which is necessary if we want to create an ERC1155Permit that would set approvals based on signatures.
The text was updated successfully, but these errors were encountered:
🧐 Motivation
It is impossible to extend ERC-1155 in a way that the derived contract is accessing the
_operatorApprovals
, because the mapping isprivate
and there is no internal method to modify it. Thus, only the ERC1155 contract itself can set or unset approvals. This makes extensions like an ERC1155Permit impossible as they need a way to modify the approval mapping. The proposal is to add an internal function, which can be used in contracts extending ERC1155 to modify_operatorApprovals
.📝 Details
Contracts extending ERC1155 need a way to modify
_operatorApprovals
. There are two options:_operatorApprovals
visibility fromprivate
tointernal
internal
function to modify the mapping.The proposal is for option two as it aligns well with ERC20, which has a similar setup:
private _allowances
, which can be modfied in derived contracts with_approve(owner, spender, amount)
.The function to be added to ERC1155 is this:
The main difference to the existing
public setApprovalForAll(address operator, bool approved)
is that it allows to add approvals for other owners thanmsg.sender
, which is necessary if we want to create an ERC1155Permit that would set approvals based on signatures.The text was updated successfully, but these errors were encountered: