This is outdated: The ERC-20 is here: ethereum/EIPs#20
function totalSupply() constant returns (uint256 supply)
Get the total coin supply
function balanceOf(address _address) constant returns (uint256 balance)
Get the account balance of another account with address _address
function transfer(address _to, uint256 _value) returns (bool _success)
Send _value
amount of coins to address _to
function transferFrom(address _from, address _to, uint256 _value) returns (bool success)
Send _value
amount of coins from address _from
to address _to
The transferFrom
method is used for a "direct debit" workflow, allowing contracts to send coins 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:
function approve(address _address) returns (bool success)
Allow _address
to direct debit from your account with full custody. Only implement if absolutely required and use carefully. See approveOnce
below for a more limited method.
function unapprove(address _address) returns (bool success)
Unapprove address _address
to direct debit from your account if it was previously approved. Must reset both one-time and full custody approvals.
function isApprovedFor(address _target, address _proxy) constant returns (bool success)
Returns 1 if _proxy
is allowed to direct debit from _target
function approveOnce(address _address, uint256 _maxValue) returns (bool success)
Makes a one-time approval for _address
to send a maximum amount of currency equal to _maxValue
function isApprovedOnceFor(address _target, address _proxy) returns (uint256 maxValue)
Returns _maxValue
if _proxy
is allowed to direct debit the returned maxValue
from address _target
only once. The approval must be reset on any transfer by _proxy
of _maxValue
or less.
event Transfer(address indexed _from, address indexed _to, uint256 _value)
Triggered when tokens are transferred.
event AddressApproval(address indexed _address, address indexed _proxy, bool _result)
Triggered when an _address
approves _proxy
to direct debit from their account.
event AddressApprovalOnce(address indexed _address, address indexed _proxy, uint256 _value)
Triggered when an _address
approves _proxy
to direct debit from their account only once for a maximum of _value
@frozeman @ethers the problem with adding identifiers is that 1) it costs more to deploy, where most token types won't use it as much, 2) it adds additional complexity. If a normal transfer without identifier is called, should it map to the identifier system? If so, should it default to 0 as the identifier? Or contract address? If it creates separate balances (one with identifiers & one without), then that's a lot of overhead for a standard token to deploy each time?
@alexvandesande I'm not sure how costly it is, but it seems we can have a more elegant solution? The approval tango seems to be fine for things like exchanges (since you can accept that a deposit can be made). For wallets, it can still work like this as well. You approve the wallet to withdraw funds and then a tx is sent to allow it to withdraw funds to the wallet account. Not ideal from a UX perspective though (unless it's all hidden away). You have to issue more than one transaction. The other option is that dapps who work with tokens have an "audit" or "check" button to see if funds have been received so that their internal ledgers can be updated (or whatever else needs to happen).
I guess I'm not sure what the best solution is here. I'd like it to be separated, and not have token contracts prodding recipients the whole time. What do you think?
There are potentially cues we can take from Bitcoin & Ether itself, in the sense that you don't actually send it to someone else. You only allow a new person an approval to send it onwards... I'll have to think some more.