-
Notifications
You must be signed in to change notification settings - Fork 848
Add ERC: Temporary Approval Extension for ERC-20 #358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
a7dffe7
Add Transient Approval Extension for ERC-20
byshape d7eefe8
Fixed EIP requirements
byshape 3eacea2
Update ERCS/eip-draft-tae-erc20.md
byshape 11e2cce
Renamed file and added link to the discussion
byshape 85f7d71
Fixed description
byshape a0d173e
Updated authors
byshape 87ac36d
Apply suggestions from code review
byshape 5146bb9
Merge branch 'master' into transient-approve
byshape fba3948
Replaced transient => temporary
byshape c5e98c2
Refined the Specification, Rationale and Backwards Compatibility sect…
byshape 17a2741
Generalise the temporary storage description
byshape d70eb46
update based on PR comments
Amxx fe09677
Update ERCS/erc-7674.md
Amxx 9d5885a
Merge pull request #1 from Amxx/transient-approve
byshape 3c10621
Update based on PR comments
byshape 1ce1aae
fix erc/eip links
ZumZoom 8a11a87
Merge branch 'master' into transient-approve
byshape 722f023
Updated based on PR comments
byshape 51b7148
Update erc-7674.md: fix eip links
SamWilsn b7978f8
Update erc-7674.md
SamWilsn b3456ce
Merge branch 'transient-approve' into transient-approve-wip
byshape 6171b37
Merge pull request #2 from byshape/transient-approve-wip
byshape 2ec28b5
Merge branch 'master' into transient-approve
byshape 7dd0208
Update erc-7674.md
SamWilsn 31079e6
Update erc-7674.md
SamWilsn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
update based on PR comments
- Loading branch information
commit d70eb46f4f3880ceac07ad33f01ce6abf8e6f85c
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| --- | ||
| eip: 7674 | ||
| title: Temporary Approval Extension for ERC-20 | ||
| description: An interface for ERC-20 approvals via transient storage | ||
| description: An interface for ephemeral ERC-20 approvals | ||
| author: Xenia Shape (@byshape), Mikhail Melnik (@ZumZoom), Hadrien Croubois (@Amxx) | ||
| discussions-to: https://ethereum-magicians.org/t/add-erc-7674-transient-approval-extension-for-erc-20/19521 | ||
| status: Draft | ||
|
|
@@ -13,11 +13,11 @@ requires: 20, 1153 | |
|
|
||
| ## Abstract | ||
|
|
||
| This specification defines the minimum interface required to temporarily approve `ERC-20` tokens for spending within a single transaction. | ||
| This specification defines the minimum interface required to temporarily approve `ERC-20` tokens for spending within the same transaction. | ||
|
|
||
| ## Motivation | ||
|
|
||
| `EIP-1153` allows to use a cheaper way to temporarily store allowances. | ||
| User are often require to set token approval that will only be used once. It is common to leave unexpected approvals after these interactions. [EIP-1153](./eip-1153.md) introduces a cheap way to handle temporarily allowances. | ||
|
||
|
|
||
| ## Specification | ||
|
|
||
|
|
@@ -27,15 +27,15 @@ Compliant contracts MUST implement 1 new function in addition to `ERC-20`: | |
| ```solidity | ||
| function temporaryApprove(address spender, uint256 value) public returns (bool success) | ||
| ``` | ||
| Call to `temporaryApprove(spender, value)` allows `spender` to withdraw within the same transaction from `msg.sender` multiple times, up to the `value` amount. | ||
| Call to `temporaryApprove(spender, value)` allows `spender` to withdraw within the same transaction from `msg.sender` multiple times, up to the `value` amount. This temporary allowance is to be considered in addition to the normal (persistent) ERC20 allowance, the total value than spender is able to spend during the transaction is thus capped by the sum of the temporary and the normal (persistent) allowances. | ||
|
|
||
| The storage for the temporary allowances MUST be different to that of the regular allowance. Compliant contracts MAY use the transient storage `EIP-1153` to keep the temporary allowance. For each `owner` and `spender`, the slot MUST be uniquely selected to avoid slot collision. Each slot index SHOULD be derived from the base slot index for temporary allowances, `owner` and `spender` addresses. Slot MAY be derived as `keccak256(spender . keccak256(owner . p))` where `.` is concatenation and `p` is `keccak256` from the string uniquely defining temporary allowances in the namespace of the implementing contract. | ||
|
|
||
| Compliant contracts MUST add a temporary allowance check to the `transferFrom` function. The permanent allowance SHOULD only be spent after the temporary allowance has been exhausted. | ||
|
|
||
| Compliant contracts MUST add a temporary allowance to the permanent one when returning the allowed amount to spend in the `allowance` function. In case the sum of the temporary and permanent allowance overflow, `type(uint256).max` MUST be returned. | ||
|
|
||
| No event is required when setting a temporary allowance, but compliant contracts MAY implement it. | ||
| No event is required when setting a temporary allowance, but compliant contracts MAY emit a specific event. | ||
byshape marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Rationale | ||
|
|
||
|
|
@@ -47,7 +47,7 @@ All functionality of the `ERC-20` standard is backward compatible except for the | |
|
|
||
| ## Reference Implementation | ||
|
|
||
| TBD | ||
| TBD <!-- TODO --> | ||
|
|
||
| ## Security Considerations | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.