Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ERCS/erc-3009.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
requires: 20, 712
---

## Simple Summary

Check warning on line 13 in ERCS/erc-3009.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

warning[markdown-order-section]: body has extra section(s) --> ERCS/erc-3009.md | 13 | ## Simple Summary | ::: ERCS/erc-3009.md | 392 | ## Implementation | = help: see https://ethereum.github.io/eipw/markdown-order-section/

A contract interface that enables transferring of fungible assets via a signed authorization.

Expand Down Expand Up @@ -41,7 +41,7 @@

This can be especially problematic if the gas prices are very high and transactions often get queued up and remain unconfirmed for a long time. Non-sequential nonces allow users to create as many transactions as they want at the same time.

The ERC-20 allowance mechanism is susceptible to the [multiple withdrawal attack](https://blockchain-projects.readthedocs.io/multiple_withdrawal.html)/[SWC-114](https://swcregistry.io/docs/SWC-114), and encourages antipatterns such as the use of the "infinite" allowance. The wide-prevalence of upgradeable contracts have made the conditions favorable for these attacks to happen in the wild.

Check warning on line 44 in ERCS/erc-3009.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

warning[markdown-rel-links]: non-relative link or image --> ERCS/erc-3009.md | 44 | The ERC-20 allowance mechanism is susceptible to the [multiple withdrawal attack](https://blockchain-projects.readthedocs.io/multipl... | = help: see https://ethereum.github.io/eipw/markdown-rel-links/

The deficiencies of the ERC-20 allowance pattern brought about the development of alternative token standards such as the [ERC-777](./eip-777) and [ERC-677](https://github.com/ethereum/EIPs/issues/677). However, they haven't been able to gain much adoption due to compatibility and potential security issues.

Expand Down Expand Up @@ -197,7 +197,7 @@

```
// "‖" denotes concatenation.
Digest := Keecak256(
Digest := Keccak256(
0x1901 ‖ DomainSeparator ‖ Keccak256(ABIEncode(TypeHash, Params...))
)

Expand Down Expand Up @@ -310,9 +310,9 @@

## Backwards Compatibility

New contracts benefit from being able to directly utilize EIP-3009 in order to create atomic transactions, but existing contracts may still rely on the conventional ERC-20 allowance pattern (`approve`/`transferFrom`).

Check warning on line 313 in ERCS/erc-3009.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

warning[markdown-link-first]: the first match of the given pattern must be a link --> ERCS/erc-3009.md | 313 | New contracts benefit from being able to directly utilize EIP-3009 in order to create atomic transactions, but existing contracts m... | = info: the pattern in question: `(?i)(?:eip|erc)-([0-9])+` = help: see https://ethereum.github.io/eipw/markdown-link-first/

In order to add support for EIP-3009 to existing contracts ("parent contract") that use the ERC-20 allowance pattern, a forwarding contract ("forwarder") can be constructed that takes an authorization and does the following:

Check warning on line 315 in ERCS/erc-3009.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

warning[markdown-link-first]: the first match of the given pattern must be a link --> ERCS/erc-3009.md | 315 | In order to add support for EIP-3009 to existing contracts ("parent contract") that use the ERC-20 allowance pattern, a forwarding ... | = info: the pattern in question: `(?i)(?:eip|erc)-([0-9])+`

1. Extract the user and deposit amount from the authorization
2. Call `receiveWithAuthorization` to transfer specified funds from the user to the forwarder
Expand Down Expand Up @@ -387,11 +387,11 @@

## Test Cases

See [EIP3009.test.ts](https://github.com/CoinbaseStablecoin/eip-3009/blob/master/test/EIP3009.test.ts).

Check warning on line 390 in ERCS/erc-3009.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

warning[markdown-re-eip-dash]: proposals must be referenced with the form `EIP-N` (not `EIPN` or `EIP N`) --> ERCS/erc-3009.md | 390 | See [EIP3009.test.ts](https://github.com/CoinbaseStablecoin/eip-3009/blob/master/test/EIP3009.test.ts). | = info: the pattern in question: `(?i)eip[\s]*[0-9]+` = help: see https://ethereum.github.io/eipw/markdown-re-eip-dash/

## Implementation

**EIP3009.sol**

Check warning on line 394 in ERCS/erc-3009.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

warning[markdown-re-eip-dash]: proposals must be referenced with the form `EIP-N` (not `EIPN` or `EIP N`) --> ERCS/erc-3009.md | 394 | **EIP3009.sol** | = info: the pattern in question: `(?i)eip[\s]*[0-9]+`
```solidity
abstract contract EIP3009 is IERC20Transfer, EIP712Domain {
// keccak256("TransferWithAuthorization(address from,address to,uint256 value,uint256 validAfter,uint256 validBefore,bytes32 nonce)")
Expand Down Expand Up @@ -454,7 +454,7 @@
}
```

**IERC20Transfer.sol**

Check warning on line 457 in ERCS/erc-3009.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

warning[markdown-re-erc-dash]: proposals must be referenced with the form `ERC-N` (not `ERCN` or `ERC N`) --> ERCS/erc-3009.md | 457 | **IERC20Transfer.sol** | = info: the pattern in question: `(?i)erc[\s]*[0-9]+` = help: see https://ethereum.github.io/eipw/markdown-re-erc-dash/
```solidity
abstract contract IERC20Transfer {
function _transfer(
Expand All @@ -465,14 +465,14 @@
}
```

**EIP712Domain.sol**

Check warning on line 468 in ERCS/erc-3009.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

warning[markdown-re-eip-dash]: proposals must be referenced with the form `EIP-N` (not `EIPN` or `EIP N`) --> ERCS/erc-3009.md | 468 | **EIP712Domain.sol** | = info: the pattern in question: `(?i)eip[\s]*[0-9]+`
```solidity
abstract contract EIP712Domain {
bytes32 public DOMAIN_SEPARATOR;
}
```

**EIP712.sol**

Check warning on line 475 in ERCS/erc-3009.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

warning[markdown-re-eip-dash]: proposals must be referenced with the form `EIP-N` (not `EIPN` or `EIP N`) --> ERCS/erc-3009.md | 475 | **EIP712.sol** | = info: the pattern in question: `(?i)eip[\s]*[0-9]+`
```solidity
library EIP712 {
// keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")
Expand Down Expand Up @@ -521,7 +521,7 @@
}
```

A fully working implementation of EIP-3009 can be found in [this repository](https://github.com/CoinbaseStablecoin/eip-3009/blob/master/contracts/lib/EIP3009.sol). The repository also includes [an implementation of EIP-2612](https://github.com/CoinbaseStablecoin/eip-3009/blob/master/contracts/lib/EI32612.sol) that uses the EIP-712 library code presented above.

Check warning on line 524 in ERCS/erc-3009.md

View workflow job for this annotation

GitHub Actions / EIP Walidator

warning[markdown-link-first]: the first match of the given pattern must be a link --> ERCS/erc-3009.md | 524 | A fully working implementation of EIP-3009 can be found in [this repository](https://github.com/CoinbaseStablecoin/eip-3009/blob/ma... | = info: the pattern in question: `(?i)(?:eip|erc)-([0-9])+`

## Security Considerations

Expand Down
Loading