글 수 1,441

이더리움과 스마트 컨트랙 - 30분만에 ICO하기

조회 수 603 와드 수 0 추천 수 2 2018.02.22 01:05:24
profile


이 글에 와드 등록

30분만에 ICO하기

 

안녕하세요. 오늘은 조금 자극적인 제목을 가지고 와봤습니다. 요즘 ICO 많이들 참여하시고,  직접 하시는 분들도 많이 계신데요. ICO에 필요한 토큰을 단 30분 만에 발행하는 방법을 소개해볼까 합니다.

 

준비물은 단 한 가지. mist 지갑입니다. 이 mist 지갑에는 스마트 컨트랙을 발행하는 기능이 있는데요. 여기에 아래와 같이 ERC20 표준에 해당하는 코드를 넣고 발행하기만 하면, 순식간에 토큰 하나가 뚝딱 만들어집니다.

 

코드 예시 : 

 

pragma solidity ^0.4.16;

interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; }

contract TokenERC20 {

    // Public variables of the token

    string public name;

    string public symbol;

    uint8 public decimals = 18;

    // 18 decimals is the strongly suggested default, avoid changing it

    uint256 public totalSupply;

    // This creates an array with all balances

    mapping (address => uint256) public balanceOf;

    mapping (address => mapping (address => uint256)) public allowance;

    // This generates a public event on the blockchain that will notify clients

    event Transfer(address indexed from, address indexed to, uint256 value);

    // This notifies clients about the amount burnt

    event Burn(address indexed from, uint256 value);

    /**

     * Constructor function

     *

     * Initializes contract with initial supply tokens to the creator of the contract

     */

    function TokenERC20(

        uint256 initialSupply,

        string tokenName,

        string tokenSymbol

    ) public {

        totalSupply = initialSupply * 10 ** uint256(decimals);  // Update total supply with the decimal amount

        balanceOf[msg.sender] = totalSupply;                // Give the creator all initial tokens

        name = tokenName;                                   // Set the name for display purposes

        symbol = tokenSymbol;                               // Set the symbol for display purposes

    }

    /**

     * Internal transfer, only can be called by this contract

     */

    function _transfer(address _from, address _to, uint _value) internal {

        // Prevent transfer to 0x0 address. Use burn() instead

        require(_to != 0x0);

        // Check if the sender has enough

        require(balanceOf[_from] >= _value);

        // Check for overflows

        require(balanceOf[_to] + _value > balanceOf[_to]);

        // Save this for an assertion in the future

        uint previousBalances = balanceOf[_from] + balanceOf[_to];

        // Subtract from the sender

        balanceOf[_from] -= _value;

        // Add the same to the recipient

        balanceOf[_to] += _value;

        Transfer(_from, _to, _value);

        // Asserts are used to use static analysis to find bugs in your code. They should never fail

        assert(balanceOf[_from] + balanceOf[_to] == previousBalances);

    }

    /**

     * Transfer tokens

     *

     * Send `_value` tokens to `_to` from your account

     *

     * @param _to The address of the recipient

     * @param _value the amount to send

     */

    function transfer(address _to, uint256 _value) public {

        _transfer(msg.sender, _to, _value);

    }

    /**

     * Transfer tokens from other address

     *

     * Send `_value` tokens to `_to` on behalf of `_from`

     *

     * @param _from The address of the sender

     * @param _to The address of the recipient

     * @param _value the amount to send

     */

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

        require(_value <= allowance[_from][msg.sender]);     // Check allowance

        allowance[_from][msg.sender] -= _value;

        _transfer(_from, _to, _value);

        return true;

    }

    /**

     * Set allowance for other address

     *

     * Allows `_spender` to spend no more than `_value` tokens on your behalf

     *

     * @param _spender The address authorized to spend

     * @param _value the max amount they can spend

     */

    function approve(address _spender, uint256 _value) public

        returns (bool success) {

        allowance[msg.sender][_spender] = _value;

        return true;

    }

    /**

     * Set allowance for other address and notify

     *

     * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it

     *

     * @param _spender The address authorized to spend

     * @param _value the max amount they can spend

     * @param _extraData some extra information to send to the approved contract

     */

    function approveAndCall(address _spender, uint256 _value, bytes _extraData)

        public

        returns (bool success) {

        tokenRecipient spender = tokenRecipient(_spender);

        if (approve(_spender, _value)) {

            spender.receiveApproval(msg.sender, _value, this, _extraData);

            return true;

        }

    }

    /**

     * Destroy tokens

     *

     * Remove `_value` tokens from the system irreversibly

     *

     * @param _value the amount of money to burn

     */

    function burn(uint256 _value) public returns (bool success) {

        require(balanceOf[msg.sender] >= _value);   // Check if the sender has enough

        balanceOf[msg.sender] -= _value;            // Subtract from the sender

        totalSupply -= _value;                      // Updates totalSupply

        Burn(msg.sender, _value);

        return true;

    }

    /**

     * Destroy tokens from other account

     *

     * Remove `_value` tokens from the system irreversibly on behalf of `_from`.

     *

     * @param _from the address of the sender

     * @param _value the amount of money to burn

     */

    function burnFrom(address _from, uint256 _value) public returns (bool success) {

        require(balanceOf[_from] >= _value);                // Check if the targeted balance is enough

        require(_value <= allowance[_from][msg.sender]);    // Check allowance

        balanceOf[_from] -= _value;                         // Subtract from the targeted balance

        allowance[_from][msg.sender] -= _value;             // Subtract from the sender's allowance

        totalSupply -= _value;                              // Update totalSupply

        Burn(_from, _value);

        return true;

    }

}

 

 

 

KakaoTalk_20180218_203831395.png

 

 

 

어때요 정말 쉽지 않나요? SUPERTOKEN이라는 이름을 가진 토큰이 하나 만들어졌습니다. 이 과정에서 가장 어려운 일은 mist 지갑을 준비하는 일입니다. mist 지갑은 이더리움 네트워크와 싱크를 맞추기 위해서 상당한 시간이 소요됩니다. 적어도 하루는 잡아야 하고요. PC 사양에 따라서 오래 걸릴 경우에는 일주일 이상 소요될 수 있습니다.

 

여기서 우리는 몇 가지 시사점을 얻을 수 있습니다.

 

 

1. 생각보다 많은 ICO들이 이런 허접한 컨트랙을 가지고 ICO를 진행합니다. 컨트랙이 공개된 몇몇 해외 유명 ICO들과 국내 ICO들을 뒤져보면, 30분 만에 찍어낸 수준으로 토큰을 발행한 곳들이 많습니다. ICO에 거액이 투자되는데도 사람들은 내용을 모르고 너무 쉽게 쉽게들 투자하죠. 

 

2. 그렇지만 토큰 발행에는 그닥 많은 기능이 필요하지 않은 게 사실이기도 합니다. 요즘 ICO에 필수라고 여겨지는 KYC나 토큰 전송 기능, 아무나 컨트랙에 손대지 못하게 하는 권한 분배, 최근 NEM 해킹 사태처럼 비상 사태가 발생했을 때 대처할 수 있는 기능들, DApp 개발 후에 포크를 위한 포크 기능 정도면 충분합니다. 그러나 이정도도 없이 30분 완성 컨트랙으로 적당히 ICO를 때우려는 사람들이 있는 것도 사실이죠.

 

3. ICO는 끝이 아니라 시작입니다. 많은 ICO 주최자들과 심지어는 참여자들까지도 간과하고 있는 사실이 바로 ICO는 시작에 불과하다는 점입니다. 주최자들은 물론이고 주최자들을 감시해야 할 참여자들까지도 투더문을 외치는 모습이 바람직하다고만 볼 수는 없습니다. ICO는 DApp을 만들고 사람들이 원하는 서비스를 제공하기 위해 시작하는 것인데, ICO로 거액을 모았다고 해서 그것이 끝인 것처럼 행동해서는 안된다는 것이죠.

 

 

마치며, 첫 ICO를 준비하는 개발자들에게 도움이 될만한 것들을 적어봅니다. 

 

1) minime token (https://github.com/Giveth/minime)

 

미니미 토큰은 포크를 하기 위해 적합한 라이브러리입니다. 소스들을 뜯어보면 알겠지만, 정말 손쉽게 다음 버전의 토큰을 만들어낼 수 있습니다. 토큰 배분 후에 개발을 진행하고, 개발 후에 새로운 기능을 추가해서 토큰 홀더들에게 새 토큰을 발행하는 것까지 이미 완성되어 있습니다. 실제 사용할 때는 약간 수정할 부분들이 있지만, 사용하기에 큰 무리가 없습니다.

 

2) ICO Wizard(https://wizard.oracles.org/)

 

ICO Wizard는 ICO를 준비하는 사람들을 위해서 만들어졌고, 원하는 정보들을 입력하면 필요한 코드를 생성해줍니다. 그대로 사용하기는 무리가 있지만 베이스가 없는 상황에서 구조를 설계하는 것엔 많은 도움이 됩니다. 

글이 재밌거나 유용하다면 좋아요를 눌러주세요.

게시물 신고
이 글에 와드 등록
태그

profile

원팡

2018.02.22 20:22

와!! 간만에 제대로 된 정보글 감사합니다! ㅎ

역시 투자는 신중하게 접근해야겠죠!

댓글을 작성하시려면 로그인이 필요합니다.

네이버 ID로 로그인

List of Articles
번호 제목 글쓴이 날짜 조회 수
공지 원팡 사이트를 오픈했어요. file 3 원팡 2017.04.14 4,440
공지 가상화폐 매매에서 가장 중요한 요점 (오늘 술자님과 커피한잔) 17 툴리가영 2018.01.10 11,142
공지 (타산지석3탄) 채팅방에서 자주 나오는 질문 답변 모음. file 12 모나리 2018.01.07 8,575
공지 이제 막 암호화화폐에 입문하신 툴리님 방송 시청자를 위한 차트보는 법. file 11 모나리 2018.01.04 18,139
1261 인기 비트맥스 수익인증 file 2 열혈청년 2018.02.24 1,775
1260 인기 비트멕스(비트맥스) 가입주소 원팡 2018.02.24 4,786
1259 인생은 몰빵입니다. 새로운 마음으로 file 1 인생은몰빵 2018.02.23 621
1258 02/23 18시35분 - 해외비트코인 동향 file 딕짱 2018.02.23 294
1257 MEW지갑 관련해서 질문 있습니다 file 후댱공듀 2018.02.23 259
1256 역대 비트코인 월별 추세 file 대구공항근처 2018.02.22 773
1255 다시돌아온 떡락무새(2014와 2018하락장 비교 2) file 1 두루미의비상 2018.02.22 718
1254 비플 SFD 패치 예고 공지가 떴습니다. 가즈아찡긋 2018.02.22 345
» 이더리움과 스마트 컨트랙 - 30분만에 ICO하기 file 1 파이리 2018.02.22 603
1252 02/21 21시30분 - 해외비트코인 동향 file 1 딕짱 2018.02.21 364
1251 02/20 11시30분 - 해외비트코인 동향 file 3 딕짱 2018.02.20 411
1250 혹시 코인 채굴 관련 아시는분?? file 2 S3ST0 2018.02.19 259
1249 농사매매 38탄 새복 많이받으세요 툴리님 file 1 꾸리꾸리꾸꾸 2018.02.18 620
1248 엔화 일봉차트 이렇게 해석가능한가요? file 4 레미아르 2018.02.17 662
1247 ICO참여했는데 이더리움을 다른곳으로보내버렸어요 file 데이지 2018.02.16 354
1246 인기 잼라이브 상금 백만원 가즈아! file 1 원팡 2018.02.15 2,477
1245 02/15 00시45분 - 해외비트코인 동향 file 딕짱 2018.02.15 537
1244 생초보의 차트 전망 file 장챙 2018.02.13 406
1243 02/13 10시40분~15시50분 - 해외비트코인 동향 file 3 딕짱 2018.02.13 470
1242 툴리님 시계를 좀 넣어주세요~ 1 누리다니 2018.02.12 370

위로
2024-04-20
2024-04-03
2024-03-04
2024-02-06
2024-01-30
2024-01-23
2024-01-18
2024-01-18
생굴 1키로 - 원팡 file
2024-01-13
2023-12-18
2023-11-08