-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
ERC20 Token Standard #610
ERC20 Token Standard #610
Changes from 2 commits
80fa7db
4f98798
d540a40
c96876e
2af51d6
b5902d3
a447ded
ed1c87a
efa1fc7
dd7e548
94bc431
e0cc8c2
3a45fb1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
This is the suggested template for new EIPs. | ||
|
||
Note that an EIP number will be assigned by an editor. When opening a pull request to submit your EIP, please use an abbreviated title in the filename, `eip-draft_title_abbrev.md`. | ||
|
||
## Preamble | ||
|
||
EIP: <to be assigned> (I Suggest 20) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. EIP: 20 |
||
Title: <EIP title> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Title: ERC-20 Token Standard |
||
Author: Fabian Vogelsteller <[email protected]>, Vitalik Buterin <[email protected]> | ||
Type: Informational | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Type: Standard |
||
Category ERC | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Category" line can be removed |
||
Status: Draft | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accepted |
||
Created: 2015-11-19 | ||
|
||
|
||
## Simple Summary | ||
|
||
Token standard interface. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe revise a bit? "A standard interface for tokens." ? |
||
|
||
|
||
## Abstract | ||
|
||
The following standard allows for people to implement a token standard API withing their smart contracts. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spelling: within There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would also revise this abstract: "The following standard allows for the implementation of a standard API for tokens within their smart contracts: it primarily provides basic functionality to transfer tokens and allow them to be approved to be spent by another on-chain third party." |
||
|
||
This standard provides basic functionality for sending and approving tokens to be spend by a third party. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. grammar: use "spent" instead of spend |
||
|
||
|
||
## Motivation | ||
|
||
Following the same standard interface allows those tokens to be used in many wallets and exchanges. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another potential revision: "A standard interface allows any tokens on Ethereum to be re-used by other applications: from wallets to decentralized exchanges." |
||
|
||
|
||
## Specification | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about adding:
|
||
## Token | ||
### Methods | ||
|
||
**NOTE**: An important point is that callers should handle `false` from `returns (bool success)`. Callers should not assume that `false` is never returned! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NOTE: Callers should handle |
||
|
||
#### totalSupply | ||
|
||
``` js | ||
function totalSupply() constant returns (uint256 totalSupply) | ||
``` | ||
|
||
Get the total token supply | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use Returns rather than Get for consistency. Returns the total token supply. |
||
|
||
|
||
#### balanceOf | ||
|
||
``` js | ||
function balanceOf(address _owner) constant returns (uint256 balance) | ||
``` | ||
|
||
Get the account balance of another account with address `_owner` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returns the account balance of another account with address |
||
|
||
|
||
#### transfer | ||
|
||
``` js | ||
function transfer(address _to, uint256 _value) returns (bool success) | ||
``` | ||
|
||
Send `_value` amount of tokens to address `_to` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use "transfer" vs "Send"? |
||
|
||
|
||
#### transferFrom | ||
|
||
``` js | ||
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) | ||
``` | ||
|
||
Send `_value` amount of tokens from address `_from` to address `_to` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Transfers |
||
|
||
The `transferFrom` method is used for a withdraw workflow, allowing contracts to send tokens on your behalf, for example to "deposit" to a contract address and/or to charge fees in sub-currencies; the command should fail unless the `_from` account has deliberately authorized the sender of the message via some mechanism; we propose these standardized APIs for approval: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Few minor corrections. Removed the last line as it didn't fit in with the rest of the content. The |
||
|
||
|
||
#### approve | ||
|
||
``` js | ||
function approve(address _spender, uint256 _value) returns (bool success) | ||
``` | ||
|
||
Allow _spender to withdraw from your account, multiple times, up to the _value amount. If this function is called again it overwrites the current allowance with _value. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed formatting and a few minor changes. Allows NOTE:To prevent attack vectors like the one described here make sure to set the allowance to 0 before setting it to another value for the same spender. |
||
To prevent attack vectors like described here: https://docs.google.com/document/d/1YLPtQxZu1UAvO9cZ1O2RPXBbT0mooh4DYKjA_jp-RLM/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "like the one described here:" |
||
make sure to set the allowance to 0 before setting it to another value for the same spender. | ||
|
||
|
||
#### allowance | ||
|
||
``` js | ||
function allowance(address _owner, address _spender) constant returns (uint256 remaining) | ||
``` | ||
|
||
Returns the amount which `_spender` is still allowed to withdraw from `_owner` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add period. Returns the amount which |
||
|
||
|
||
### Events | ||
|
||
|
||
#### Transfer | ||
|
||
``` js | ||
event Transfer(address indexed _from, address indexed _to, uint256 _value) | ||
``` | ||
|
||
Triggered when tokens are transferred. | ||
|
||
|
||
#### Approval | ||
|
||
``` js | ||
event Approval(address indexed _owner, address indexed _spender, uint256 _value) | ||
``` | ||
|
||
Triggered whenever `approve(address _spender, uint256 _value)` is called. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change whenever to when. Triggered when |
||
|
||
|
||
## Implementation | ||
|
||
Different implementations are available at | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would probably change this to say: "There are already plenty of ERC20-compliant tokens deployed on the Ethereum network and is the most widely used standard. Different implementations have been written by various teams that have different trade-offs: from gas saving to improved security. Example implementations include:" |
||
- https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/StandardToken.sol | ||
- https://github.com/ConsenSys/Tokens/blob/master/Token_Contracts/contracts/StandardToken.sol | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.com/Giveth/minime/blob/master/contracts/MiniMeToken.sol There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :-D!!! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would also like to see the MiniMeToken added to this list. Maintaining historical balance data is key for a number of token use cases. |
||
Implentation adding the force 0 before calling approve again: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spelling: implementation |
||
- https://github.com/Giveth/minime/blob/master/MiniMeToken.sol | ||
|
||
## Copyright | ||
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). |
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.
Should this preamble also be included?