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
Copy file name to clipboardExpand all lines: EIPS/eip-1.md
+13-1Lines changed: 13 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ There are three types of EIP:
24
24
- A **Standards Track EIP** describes any change that affects most or all Ethereum implementations, such as—a change to the network protocol, a change in block or transaction validity rules, proposed application standards/conventions, or any change or addition that affects the interoperability of applications using Ethereum. Standards Track EIPs consist of three parts—a design document, an implementation, and (if warranted) an update to the [formal specification](https://github.com/ethereum/yellowpaper). Furthermore, Standards Track EIPs can be broken down into the following categories:
25
25
-**Core**: improvements requiring a consensus fork (e.g. [EIP-5](./eip-5.md), [EIP-101](./eip-101.md)), as well as changes that are not necessarily consensus critical but may be relevant to [“core dev” discussions](https://github.com/ethereum/pm) (for example, [EIP-90], and the miner/node strategy changes 2, 3, and 4 of [EIP-86](./eip-86.md)).
26
26
-**Networking**: includes improvements around [devp2p](https://github.com/ethereum/devp2p/blob/readme-spec-links/rlpx.md) ([EIP-8](./eip-8.md)) and [Light Ethereum Subprotocol](https://ethereum.org/en/developers/docs/nodes-and-clients/#light-node), as well as proposed improvements to network protocol specifications of [whisper](https://github.com/ethereum/go-ethereum/issues/16013#issuecomment-364639309) and [swarm](https://github.com/ethereum/go-ethereum/pull/2959).
27
-
-**Interface**: includes improvements around client [API/RPC](https://github.com/ethereum/execution-apis#README) specifications and standards, and also certain language-level standards like method names ([EIP-6](./eip-6.md)) and [contract ABIs](https://docs.soliditylang.org/en/develop/abi-spec.html). The label “interface” aligns with the [interfaces repo] and discussion should primarily occur in that repository before an EIP is submitted to the EIPs repository.
27
+
-**Interface**: includes improvements around language-level standards like method names ([EIP-6](./eip-6.md)) and [contract ABIs](https://docs.soliditylang.org/en/develop/abi-spec.html).
28
28
-**ERC**: application-level standards and conventions, including contract standards such as token standards ([ERC-20](./eip-20.md)), name registries ([ERC-137](./eip-137.md)), URI schemes, library/package formats, and wallet formats.
29
29
30
30
- A **Meta EIP** describes a process surrounding Ethereum or proposes a change to (or an event in) a process. Process EIPs are like Standards Track EIPs but apply to areas other than the Ethereum protocol itself. They may propose an implementation, but not to Ethereum's codebase; they often require community consensus; unlike Informational EIPs, they are more than recommendations, and users are typically not free to ignore them. Examples include procedures, guidelines, changes to the decision-making process, and changes to the tools or environment used in Ethereum development. Any meta-EIP is also considered a Process EIP.
@@ -326,6 +326,18 @@ Permitted Bitcoin Improvement Proposal URLs must anchor to a specific commit, an
Links to the Common Vulnerabilities and Exposures (CVE) system as published by the National Institute of Standards and Technology (NIST) may be included, provided they are qualified by the date of the most recent change, using the following syntax:
@@ -19,7 +18,7 @@ The following describes an interface and logic for fungible tokens that supports
19
18
20
19
This token introduces a communication model for contracts that can be utilized to straighten the behavior of contracts that interact with such tokens. Specifically, this proposal:
21
20
22
-
1. Informs receiving contracts of tokens, as opposed to [ERC-20](./eip-20.md) where the recipient of a token transfer gets no notification.
21
+
1. Informs receiving contracts of incoming token transfers, as opposed to [ERC-20](./eip-20.md) where the recipient of a token transfer gets no notification.
23
22
2. Is more gas-efficient when depositing tokens to contracts.
24
23
3. Allows for `_data` recording for financial transfers.
25
24
@@ -36,15 +35,15 @@ Token transfers to contracts not implementing `tokenReceived` as described below
36
35
##### `totalSupply`
37
36
38
37
```solidity
39
-
function totalSupply() view returns (uint256 totalSupply)
38
+
function totalSupply() view returns (uint256)
40
39
```
41
40
42
41
Returns the total supply of the token. The functionality of this method is identical to that of ERC-20.
43
42
44
43
##### `name`
45
44
46
45
```solidity
47
-
function name() view returns (string _name)
46
+
function name() view returns (string memory)
48
47
```
49
48
50
49
Returns the name of the token. The functionality of this method is identical to that of ERC-20.
@@ -54,7 +53,7 @@ OPTIONAL - This method can be used to improve usability, but interfaces and othe
54
53
##### `symbol`
55
54
56
55
```solidity
57
-
function symbol() view returns (string _symbol)
56
+
function symbol() view returns (string memory)
58
57
```
59
58
60
59
Returns the symbol of the token. The functionality of this method is identical to that of ERC-20.
@@ -64,7 +63,7 @@ OPTIONAL - This method can be used to improve usability, but interfaces and othe
64
63
##### `decimals`
65
64
66
65
```solidity
67
-
function decimals() view returns (uint8 _decimals)
66
+
function decimals() view returns (uint8)
68
67
```
69
68
70
69
Returns the number of decimals of the token. The functionality of this method is identical to that of ERC-20.
@@ -84,7 +83,7 @@ OPTIONAL - This method can be used to improve usability, but interfaces and othe
84
83
##### `balanceOf`
85
84
86
85
```solidity
87
-
function balanceOf(address _owner) view returns (uint256 balance)
86
+
function balanceOf(address _owner) view returns (uint256)
88
87
```
89
88
90
89
Returns the account balance of another account with address `_owner`. The functionality of this method is identical to that of ERC-20.
@@ -99,7 +98,9 @@ This function must transfer tokens, and if `_to` is a contract, it must call the
99
98
If `_to` is an externally owned address, then the transaction must be sent without executing `tokenReceived` in `_to`.
100
99
`_data` can be attached to this token transaction, but it requires more gas. `_data` can be empty.
101
100
102
-
The `tokenReceived` function of `_to` MUST be called after all other operations to avoid re-entrancy attacks.
101
+
The `tokenReceived` function of `_to` MUST be called after all other operations to avoid re-entrancy attacks.
102
+
103
+
NOTE: If `transfer` function is `payable` and ether was deposited then the amount of deposited ether MUST be delivered to `_to` address alongside tokens. If ether was sent alongside tokens in this way then ether MUST be delivered first, then token balances must be updated, then `tokenReceived` function MUST be called in `_to` if it is a contract.
103
104
104
105
##### `transfer(address, uint, bytes)`
105
106
@@ -111,7 +112,7 @@ This function must transfer tokens and invoke the function `tokenReceived (addre
111
112
If `_to` is an externally owned address (determined by the code size being zero), then the transaction must be sent without executing `tokenReceived` in `_to`.
112
113
`_data` can be attached to this token transaction, but it requires more gas. `_data` can be empty.
113
114
114
-
NOTE: A possible way to check whether the `_to` is a contract or an address is to assemble the code of `_to`. If there is no code in `_to`, then this is an externally owned address, otherwise it's a contract.
115
+
NOTE: A possible way to check whether the `_to` is a contract or an address is to assemble the code of `_to`. If there is no code in `_to`, then this is an externally owned address, otherwise it's a contract. If `transfer` function is `payable` and ether was deposited then the amount of deposited ether MUST be delivered to `_to` address alongside tokens.
115
116
116
117
The `tokenReceived` function of `_to` MUST be called after all other operations to avoid re-entrancy attacks.
117
118
@@ -133,11 +134,11 @@ Triggered when tokens are transferred. Compatible with and similar to the ERC-20
133
134
function tokenReceived(address _from, uint _value, bytes calldata _data) returns (bytes4)
134
135
```
135
136
136
-
A function for handling token transfers, which is called from the token contract, when a token holder sends tokens. `_from` is the address of the sender of the token, `_value` is the amount of incoming tokens, and `_data` is attached data similar to `msg.data` of Ether transactions. It works by analogy with the fallback function of Ether transactions and returns nothing.
137
+
A function for handling token transfers, which is called from the token contract, when a token holder sends tokens. `_from` is the address of the sender of the token, `_value` is the amount of incoming tokens, and `_data` is attached data similar to `msg.data` of ether transactions. It works by analogy with the fallback function of Ether transactions and returns nothing.
137
138
138
139
NOTE: `msg.sender` will be a token-contract inside the `tokenReceived` function. It may be important to filter which tokens were sent (by token-contract address). The token sender (the person who initiated the token transaction) will be `_from` inside the `tokenReceived` function. The `tokenReceived` function must return `0x8943ec02` after handling an incoming token transfer. The `tokenReceived` function call can be handled by the fallback function of the recipient contact (and in this case it may not return the magic value 0x8943ec02).
139
140
140
-
IMPORTANT: This function must be named `tokenReceived` and take parameters `address`, `uint256`, `bytes` to match the function signature `0x8943ec02`.
141
+
IMPORTANT: This function must be named `tokenReceived` and take parameters `address`, `uint256`, `bytes` to match the function signature `0x8943ec02`. This function can be manually called by a EOA.
141
142
142
143
## Rationale
143
144
@@ -149,13 +150,13 @@ This standard sticks to the push transaction model where the transfer of assets
149
150
150
151
- ERC-223 deposit: `transfer` and handling on the receivers side ~54K gas
151
152
152
-
This standard introduces the ability to correct user errors by allowing to handle ANY transactions on the recipient side and reject incorrect or improper transactions. This tokens utilize ONE transferring method for both types of interactions with tokens and externally owned addresses which can simplify the user experience and allow to avoid possible user mistakes.
153
+
This standard introduces the ability to correct user errors by allowing to handle ANY transactions on the recipients side and reject incorrect or improper transfers. This tokens utilize ONE transferring method for both types of interactions with contracts and externally owned addresses which can simplify the user experience and allow to avoid possible user mistakes.
153
154
154
-
One downside of the commonly used [ERC-20](./eip-20.md) standard that ERC-223 is intended to solve is that [ERC-20](./eip-20.md) implements two methods of token transferring: (1) `transfer` function and (2) `approve + transferFrom` pattern. Transfer function of [ERC-20](./eip-20.md) standard does not notify the receiver and therefore if any tokens are sent to a contract with the `transfer` function then the receiver will not recognize this transfer and the tokens can become stuck in the receivers address without any possibility of recovering them.
155
+
One downside of the commonly used [ERC-20](./eip-20.md) standard that ERC-223 is intended to solve is that [ERC-20](./eip-20.md) implements two methods of token transferring: (1) `transfer` function and (2) `approve + transferFrom` pattern. Transfer function of [ERC-20](./eip-20.md) standard does not notify the receiver and therefore if any tokens are sent to a contract with the `transfer` function then the receiver will not recognize this transfer and the tokens can become stuck in the receivers address without any possibility of recovering them.[ERC-20](./eip-20.md) standard places the burden of determining the transferring method on the user and if the incorrect method is chosen the user can lose the transferred tokens. ERC-223 automatically determines the transferring method, preventing the user from losing tokens due to chosing wrong method.
155
156
156
157
ERC-223 is intended to simplify the interaction with contracts that are intended to work with tokens. ERC-223 utilizes a "deposit" pattern, similar to that of plain Ether. An ERC-223 deposit to a contract is a simple call of the `transfer` function. This is one transaction as opposed to two step process of `approve + transferFrom` depositing.
157
158
158
-
This standard allows payloads to be attached to transactions using the `bytes calldata _data` parameter, which can encode a second function call in the destination address, similar to how `msg.data` does in an Ether transaction, or allow for public logging on chain should it be necessary for financial transactions.
159
+
This standard allows payloads to be attached to transactions using the `bytes calldata _data` parameter, which can encode a second function call in the destination address, similar to how `msg.data` does in an ether transaction, or allow for public logging on chain should it be necessary for financial transactions.
159
160
160
161
## Backwards Compatibility
161
162
@@ -164,18 +165,18 @@ The interface of this token is similar to that of ERC-20 and most functions serv
164
165
165
166
ERC-20 tokens can be delivered to a non-contract address with `transfer` function. ERC-20 tokens can be deposited to a contract address with `approve` + `transferFrom` pattern. Depositing ERC-20 tokens to the contract address with `transfer` function will always result in token deposit not being recognized by the recipient contract.
166
167
167
-
Here is an example of the contract code that handles ERC-20 token deposit. The following contract can accepts `tokenA` deposits. It is impossible to prevent deposits of tokenA or any other ERC-20 token to this contract that are made with `transfer` function.
168
+
Here is an example of the contract code that handles ERC-20 token deposit. The following contract can accepts `tokenA` deposits. It is impossible to prevent deposits of non-tokenA to this contract. If tokenA is deposited with `transfer` function then it will result in a loss of tokens for the depositor because the balance of the user will be decreased in the contract of tokenA but the value of `deposits` variable in the `ERC20Receiver` will not be increased i.e. the deposit will not be credited. As of 5/9/2023 **$201M worth of 50 examined ERC-20 tokens are already lost** in this way on Ethereum mainnet.
168
169
169
170
```solidity
170
171
contract ERC20Receiver
171
172
{
172
-
event Deposit();
173
173
address tokenA;
174
+
mapping (address => uint256) deposits;
174
175
function deposit(uint _value, address _token) public
0 commit comments