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
@alexvandesande
Interesting idea around receipts. This is something which @SilentCicero & I have spoken about as well (calling it hooks). You ideally want a service to be notified. What would happen if a service did not implement that function? You would then still expend gas costs? Perhaps there's a more elegant way? I was thinking that these kind of notifications would depend on the application using them. ie, let's think of EtherEx. You send some tokens to it, so that it can be traded on there. You can either do 1) send tokens, and then 2) notify EtherEx through a hook that it received a deposit.
The other option is to do the approval tango. You authorise EtherEx for your address. Then on EtherEx's app page, if you use the same address, it can check for a token you specify if it is approved for a deposit. Then you can do: deposit tokens, upon which EtherEx calls transferFrom for the once off approval. Currently, I'm for the latter since it is more generic than sending a receipt each time?
@aakilfernandes
Wouldn't you then have to send tokens to the custodian to manage approvals for you (basically creating a new ledger inside the approval custodian contract)? Seems a bit more complicated, as whomever is interacting with the token contract will need to know where the custodian is if it wants this functionality. It can be separated, but I think it's generic enough to be included at this level.
@frozeman: Thanks!