본문 바로가기

white paper

EIPs ERC20 standard


EIPs : Ethereum Improvement Proposals : 이더리움 개선 제안서

ERC-20 (github:eip-20.md) : Ehtereum Request for Comment : 이더리움 표준안 20번 문서


전문

Fabian Vogelsteller와 Vitalik Buterin이 제안했으며 2015년 11월 19일에 작성되어 Accept 상태이다. 


초록

토근에 대한 표준 인터페이스


개론

다음의 표준은 스마트컨트랙트의 토큰에 대한 표준 개발을 허용한다.

본 표준은 토큰의 전송, 해당 토큰의 사용 승인으로 제3의 체인에 전송하는 기본적인 기능을 제공한다.


개발동기

표준 인터페이스는 이더리움상의 모든 토큰이 지갑에서 탈중앙거래에 이르기까지 다른어플에서 재사용가능하도록 해준다.


사양


메소드

name            : optional

symbol          : optional

decimals        : optional

totalSupply     : 

balanceOf       : 

transfer          : check return, Transfer event

transferFrom   : check return, Transfer event

approve          : withdraw multiple time

allowance       : withdraw total value


이벤트

Transfer         : must trigger

Approval        : must trigger


Example implementations are available at

https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/ERC20/StandardToken.sol

https://github.com/ConsenSys/Tokens/blob/master/contracts/eip20/EIP20.sol


Implementation of adding the force to 0 before calling "approve" again:

https://github.com/Giveth/minime/blob/master/contracts/MiniMeToken.sol


// Abstract contract for the full ERC 20 Token standard

// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md

pragma solidity ^0.4.18;



contract EIP20Interface {

    /* This is a slight change to the ERC20 base standard.

    function totalSupply() constant returns (uint256 supply);

    is replaced with:

    uint256 public totalSupply;

    This automatically creates a getter function for the totalSupply.

    This is moved to the base contract since public getter functions are not

    currently recognised as an implementation of the matching abstract

    function by the compiler.

    */

    /// total amount of tokens

    uint256 public totalSupply;


    /// @param _owner The address from which the balance will be retrieved

    /// @return The balance

    function balanceOf(address _owner) public view returns (uint256 balance);


    /// @notice send `_value` token to `_to` from `msg.sender`

    /// @param _to The address of the recipient

    /// @param _value The amount of token to be transferred

    /// @return Whether the transfer was successful or not

    function transfer(address _to, uint256 _value) public returns (bool success);


    /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`

    /// @param _from The address of the sender

    /// @param _to The address of the recipient

    /// @param _value The amount of token to be transferred

    /// @return Whether the transfer was successful or not

    function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);


    /// @notice `msg.sender` approves `_spender` to spend `_value` tokens

    /// @param _spender The address of the account able to transfer the tokens

    /// @param _value The amount of tokens to be approved for transfer

    /// @return Whether the approval was successful or not

    function approve(address _spender, uint256 _value) public returns (bool success);


    /// @param _owner The address of the account owning tokens

    /// @param _spender The address of the account able to transfer the tokens

    /// @return Amount of remaining tokens allowed to spent

    function allowance(address _owner, address _spender) public view returns (uint256 remaining);


    // solhint-disable-next-line no-simple-event-func-name  

    event Transfer(address indexed _from, address indexed _to, uint256 _value); 

    event Approval(address indexed _owner, address indexed _spender, uint256 _value);

}


'white paper' 카테고리의 다른 글

FlureeDB White paper  (0) 2018.04.20
EOS.IO DAWN 2.0 released & development update  (0) 2018.03.13
EOS.IO white paper  (0) 2018.02.13