@@ -41,44 +41,74 @@ Compliant contracts MUST implement the following interface:
4141``` solidity
4242/// @title ERC-7432 Non-Fungible Token Roles
4343/// @dev See https://eips.ethereum.org/EIPS/eip-7432
44- /// Note: the ERC-165 identifier for this interface is 0xeec2fffb .
44+ /// Note: the ERC-165 identifier for this interface is 0xd7e151ef .
4545interface IERC7432 /* is ERC165 */ {
46+
47+ /** Events **/
4648
4749 /// @notice Emitted when a role is granted.
4850 /// @param _role The role identifier.
4951 /// @param _tokenAddress The token address.
5052 /// @param _tokenId The token identifier.
51- /// @param _grantee The user that receives the role assignment.
52- /// @param _expirationDate The expiration date of the role assignment.
53- /// @param _data Any additional data about the role assignment.
53+ /// @param _grantor The user assigning the role.
54+ /// @param _grantee The user receiving the role.
55+ /// @param _expirationDate The expiration date of the role.
56+ /// @param _data Any additional data about the role.
5457 event RoleGranted(
5558 bytes32 indexed _role,
5659 address indexed _tokenAddress,
5760 uint256 indexed _tokenId,
61+ address _grantor,
5862 address _grantee,
59- uint64 _expirationDate,
63+ uint64 _expirationDate,
6064 bytes _data
6165 );
6266
6367 /// @notice Emitted when a role is revoked.
6468 /// @param _role The role identifier.
6569 /// @param _tokenAddress The token address.
6670 /// @param _tokenId The token identifier.
71+ /// @param _revoker The user revoking the role.
6772 /// @param _grantee The user that receives the role revocation.
6873 event RoleRevoked(
6974 bytes32 indexed _role,
7075 address indexed _tokenAddress,
7176 uint256 indexed _tokenId,
77+ address _revoker,
7278 address _grantee
7379 );
7480
81+ /// @notice Emitted when a user is approved to manage any role on behalf of another user.
82+ /// @param _tokenAddress The token address.
83+ /// @param _operator The user approved to grant and revoke roles.
84+ /// @param _isApproved The approval status.
85+ event RoleApprovalForAll(
86+ address indexed _tokenAddress,
87+ address indexed _operator,
88+ bool _isApproved
89+ );
90+
91+ /// @notice Emitted when a user is approved to manage the roles of an NFT on behalf of another user.
92+ /// @param _tokenAddress The token address.
93+ /// @param _tokenId The token identifier.
94+ /// @param _operator The user approved to grant and revoke roles.
95+ /// @param _isApproved The approval status.
96+ event RoleApproval(
97+ address indexed _tokenAddress,
98+ uint256 indexed _tokenId,
99+ address _operator,
100+ bool _isApproved
101+ );
102+
103+ /** External Functions **/
104+
75105 /// @notice Grants a role to a user.
76106 /// @param _role The role identifier.
77107 /// @param _tokenAddress The token address.
78108 /// @param _tokenId The token identifier.
79- /// @param _grantee The user that receives the role assignment .
80- /// @param _expirationDate The expiration date of the role assignment .
81- /// @param _data Any additional data about the role assignment .
109+ /// @param _grantee The user receiving the role.
110+ /// @param _expirationDate The expiration date of the role.
111+ /// @param _data Any additional data about the role.
82112 function grantRole(
83113 bytes32 _role,
84114 address _tokenAddress,
@@ -100,61 +130,139 @@ interface IERC7432 /* is ERC165 */ {
100130 address _grantee
101131 ) external;
102132
103- /// @notice Checks if a user has a role .
133+ /// @notice Grants a role on behalf of a user .
104134 /// @param _role The role identifier.
105135 /// @param _tokenAddress The token address.
106136 /// @param _tokenId The token identifier.
107- /// @param _grantor The role creator .
137+ /// @param _grantor The user assigning the role .
108138 /// @param _grantee The user that receives the role.
109- function hasRole(
139+ /// @param _expirationDate The expiration date of the role.
140+ /// @param _data Any additional data about the role.
141+ function grantRoleFrom(
110142 bytes32 _role,
111143 address _tokenAddress,
112144 uint256 _tokenId,
113145 address _grantor,
146+ address _grantee,
147+ uint64 _expirationDate,
148+ bytes calldata _data
149+ ) external;
150+
151+ /// @notice Revokes a role on behalf of a user.
152+ /// @param _role The role identifier.
153+ /// @param _tokenAddress The token address.
154+ /// @param _tokenId The token identifier.
155+ /// @param _revoker The user revoking the role.
156+ /// @param _grantee The user that receives the role revocation.
157+ function revokeRoleFrom(
158+ bytes32 _role,
159+ address _tokenAddress,
160+ uint256 _tokenId,
161+ address _revoker,
114162 address _grantee
115- ) external view returns (bool);
163+ ) external;
164+
165+ /// @notice Approves operator to grant and revoke any roles on behalf of another user.
166+ /// @param _tokenAddress The token address.
167+ /// @param _operator The user approved to grant and revoke roles.
168+ /// @param _approved The approval status.
169+ function setRoleApprovalForAll(
170+ address _tokenAddress,
171+ address _operator,
172+ bool _approved
173+ ) external;
116174
175+ /// @notice Approves operator to grant and revoke roles of an NFT on behalf of another user.
176+ /// @param _tokenAddress The token address.
177+ /// @param _tokenId The token identifier.
178+ /// @param _operator The user approved to grant and revoke roles.
179+ /// @param _approved The approval status.
180+ function approveRole(
181+ address _tokenAddress,
182+ uint256 _tokenId,
183+ address _operator,
184+ bool _approved
185+ ) external;
186+
187+ /** View Functions **/
188+
189+ /// @notice Checks if a user has a role.
190+ /// @param _role The role identifier.
191+ /// @param _tokenAddress The token address.
192+ /// @param _tokenId The token identifier.
193+ /// @param _grantor The user that assigned the role.
194+ /// @param _grantee The user that received the role.
195+ function hasRole(
196+ bytes32 _role,
197+ address _tokenAddress,
198+ uint256 _tokenId,
199+ address _grantor,
200+ address _grantee
201+ ) external view returns (bool);
202+
117203 /// @notice Checks if a user has a unique role.
118204 /// @param _role The role identifier.
119205 /// @param _tokenAddress The token address.
120206 /// @param _tokenId The token identifier.
121- /// @param _grantor The role creator .
122- /// @param _grantee The user that receives the role.
207+ /// @param _grantor The user that assigned the role .
208+ /// @param _grantee The user that received the role.
123209 function hasUniqueRole(
124210 bytes32 _role,
125211 address _tokenAddress,
126212 uint256 _tokenId,
127213 address _grantor,
128214 address _grantee
129215 ) external view returns (bool);
130-
216+
131217 /// @notice Returns the custom data of a role assignment.
132218 /// @param _role The role identifier.
133219 /// @param _tokenAddress The token address.
134220 /// @param _tokenId The token identifier.
135- /// @param _grantor The role creator .
136- /// @param _grantee The user that receives the role.
221+ /// @param _grantor The user that assigned the role .
222+ /// @param _grantee The user that received the role.
137223 function roleData(
138- bytes32 _role,
139- address _tokenAddress,
140- uint256 _tokenId,
141- address _grantor,
142- address _grantee
224+ bytes32 _role,
225+ address _tokenAddress,
226+ uint256 _tokenId,
227+ address _grantor,
228+ address _grantee
143229 ) external view returns (bytes memory data_);
144-
230+
145231 /// @notice Returns the expiration date of a role assignment.
146232 /// @param _role The role identifier.
147233 /// @param _tokenAddress The token address.
148234 /// @param _tokenId The token identifier.
149- /// @param _grantor The role creator .
150- /// @param _grantee The user that receives the role.
235+ /// @param _grantor The user that assigned the role .
236+ /// @param _grantee The user that received the role.
151237 function roleExpirationDate(
152- bytes32 _role,
238+ bytes32 _role,
239+ address _tokenAddress,
240+ uint256 _tokenId,
241+ address _grantor,
242+ address _grantee
243+ ) external view returns (uint64 expirationDate_);
244+
245+ /// @notice Checks if the grantor approved the operator for all NFTs.
246+ /// @param _tokenAddress The token address.
247+ /// @param _grantor The user that approved the operator.
248+ /// @param _operator The user that can grant and revoke roles.
249+ function isRoleApprovedForAll(
250+ address _tokenAddress,
251+ address _grantor,
252+ address _operator
253+ ) external view returns (bool);
254+
255+ /// @notice Checks if the grantor approved the operator for a specific NFT.
256+ /// @param _tokenAddress The token address.
257+ /// @param _tokenId The token identifier.
258+ /// @param _grantor The user that approved the operator.
259+ /// @param _operator The user approved to grant and revoke roles.
260+ function getApprovedRole(
153261 address _tokenAddress,
154262 uint256 _tokenId,
155263 address _grantor,
156- address _grantee
157- ) external view returns (uint64 expirationDate_ );
264+ address _operator
265+ ) external view returns (bool );
158266
159267}
160268```
@@ -275,9 +383,15 @@ for complex tuple types.
275383* Compliant contracts MUST implement the ` IERC7432 ` interface.
276384* A role is represented by a ` bytes32 ` , and it's RECOMMENDED to use the ` keccak256 ` of the role's name for this purpose:
277385 ` bytes32 role = keccak256("ROLE_NAME") ` .
278- * ` grantRole ` function MUST revert if the ` _expirationDate ` is in the past, and MAY be implemented as ` public ` or
386+ * The ` grantRole ` function MUST revert if the ` _expirationDate ` is in the past, and MAY be implemented as ` public ` or
279387 ` external ` .
280- * ` revokeRole ` function MAY be implemented as ` public ` or ` external ` .
388+ * The ` grantRoleFrom ` function MUST revert if the ` _expirationDate ` is in the past or if the ` msg.sender ` is not approved
389+ to grant roles on behalf of the ` _grantor ` . It MAY be implemented as ` public ` or ` external ` .
390+ * The ` revokeRole ` function MAY be implemented as ` public ` or ` external ` .
391+ * The ` revokeRoleFrom ` function MUST revert if the ` msg.sender ` is not approved to revoke roles on behalf of the ` _revoker ` .
392+ It MAY be implemented as ` public ` or ` external ` .
393+ * The ` setRoleApprovalForAll ` function MAY be implemented as ` public ` or ` external ` .
394+ * The ` approveRole ` function MAY be implemented as ` public ` or ` external ` .
281395* The ` hasRole ` function MAY be implemented as ` pure ` or ` view ` and SHOULD only confirm if the role assignment exists
282396 and is not expired (supports simultaneous role assignments).
283397* The ` hasUniqueRole ` function MAY be implemented as ` pure ` or ` view ` and SHOULD check if the assignment exists, is not
@@ -286,6 +400,10 @@ for complex tuple types.
286400 assignment does not exist.
287401* The ` roleExpirationDate ` function MAY be implemented as ` pure ` or ` view ` , and SHOULD return zero if the role
288402 assignment does not exist.
403+ * The ` isRoleApprovedForAll ` function MAY be implemented as ` pure ` or ` view ` and SHOULD only return ` true ` if the
404+ ` _operator ` is approved to grant and revoke roles for all NFTs on behalf of the ` _grantor ` .
405+ * The ` getApprovedRole ` function MAY be implemented as ` pure ` or ` view ` and SHOULD only return ` true ` if the ` _operator `
406+ is approved to grant and revoke roles for the specified NFT on behalf of the ` _grantor ` .
289407* Compliant contracts SHOULD support [ ERC-165] ( ./eip-165.md ) .
290408
291409## Rationale
@@ -321,6 +439,12 @@ generic type `bytes` to enable dApps to encode any role-specific information whe
321439data is retrievable using the ` roleData ` function and is emitted with the ` RoleGranted ` event. With this approach,
322440developers can integrate this information into their applications, both on-chain and off-chain.
323441
442+ ### Role Approval
443+
444+ Similar to [ ERC-721] ( ./eip-721.md ) , this standard enables users to approve other accounts to grant and revoke roles on
445+ its behalf. Users can authorize an account to manage a single NFT or any NFTs in a collection. This functionality was
446+ introduced to allow third-party contracts to interact with ERC-7432 without requiring ownership of the NFTs.
447+
324448## Backwards Compatibility
325449
326450On all functions and events, the standard requires both the ` tokenAddress ` and ` tokenId ` to be provided. This
0 commit comments