Skip to content

Instantly share code, notes, and snippets.

@mrsinguyen
Created June 5, 2017 06:01
Show Gist options
  • Save mrsinguyen/cce2521099b6281899ade4077cadecc4 to your computer and use it in GitHub Desktop.
Save mrsinguyen/cce2521099b6281899ade4077cadecc4 to your computer and use it in GitHub Desktop.
ICOs & Custom Cryptocurrencies On Ethereum Classic

fund raising

Many initiatives are raising capital via initial coin offerings (ICOs). The Ethereum (ETH) project raised 18 million dollars and the DAO project raised 150 million of dollars! Furthermore, the entire blockchain space is worth over 90 billion dollars! I will describe ICOs and their custom cryptocurrencies on Ethereum Classic (ETC).

ICO Basics

ICO

An ICO is a method of raising funds via the sale of a new cryptocurrency. These cryptocurrencies are often required to purchase goods and services from the issuing organizations. For example, the ETH cryptocurrency (ether) is used to rent ETH system resources. Typically ICOs are announced on Bitcointalk.org forums and heavily marketed beforehand. Buyers often purchase new cryptocurrencies by sending bitcoins or ether to an escrow account. Organizations set the initial prices then supply and demand determines the future prices. If the organizations are well managed, and their cryptocurrencies prove useful, they should increase in value. If prices skyrocket, miniscule cryptocurrency subdivisions can typically be used. For example, ETC cryptocurrency tokens can be subdivided into as many as 1018 pieces if desired.

Caution is required with ICOs as they are effectively unregulated. Participants do not purchase ownership in companies, nor, many privileges protected by established case law. There is great potential for innovation as well as scams. Due diligence is required. Smith & Crown and ICOrating are two resources that can assist in ICO research.

ICO Cryptocurrencies

currencies

Cryptocurrencies are implemented with smart contracts. ETC provides an excellent ICO smart contract platform. It has all of the functionality of ETH at a fraction of the cost. A lot of the necessary functionality is automatically provided by the ETC blockchain itself.

Many exchanges and other users prefer that crytocurrencies adhere to the Ethereum Token Standard. This standard specifies the following interfaces for cryptocurrency smart contracts:

INTERFACE DESCRIPTION
transfer(receiving_address, transfer_amount) Transfers funds between accounts.
balanceOf(account_address) Returns the account balance.
totalSupply() Returns the total supply.

The standard also specifies the following interfaces for when a user wants another account to also manage their funds:

INTERFACE DESCRIPTION
approve(approved_address, approved_amount) Allows another account to transfer funds.
transferFrom(sending_address, receiving_address, transfer_amount) Transfers funds between accounts.
allowance(shared_address, approved_address) Returns the remaining approved amount.

It is also common to include the following named constants:

NAMED CONSTANT DESCRIPTION
name cryptocurrency name
symbol cryptocurrency ticker symbol
decimals cryptocurrency maximum number of subdivision decimal places

For example, the ETC cryptocurrency ticker symbol is ETC. Since the ETC cryptocurrency tokens can be divided into as many as 1018 pieces, the maximum number of subdivision decimal places is 18.

Sample Code

There are many open source Solidity Ethereum Token Standard compliant smart contract examples available. Here is an example of a Serpent cryptocurrency smart contract:

#
# Implements a cryptocurrency.
#
# Contains the Ethereum Token Standard interfaces.
#

data NAME
data SYMBOL
data DECIMALS
data TOTAL_SUPPLY

data balance[]
data allowed[][]

def init():
        #
        # Initializes the values in storage.
        #

        self.NAME                = "Example"
        self.SYMBOL              = "EXPL"
        self.DECIMALS            = 18
        self.TOTAL_SUPPLY        = 1000000
        self.balance[msg.sender] = self.TOTAL_SUPPLY

def valid_transfer(sending_add, receiving_add, transfer_amount):
        #
        # Determines whether a transfer is valid or not.
        #

        positive_amount   = transfer_amount > 0
        sufficient_funds  = self.balance[sending_add]   > transfer_amount
        new_receiving_bal = self.balance[receiving_add] + transfer_amount
        no_overflow       = new_receiving_bal > self.balance[receiving_add]

        return positive_amount and sufficient_funds and no_overflow

def balanceOf(account_add):
        #
        # Returns the account balance.
        #

        return self.balance[account_add]

def totalSupply(account_add):
        #
        # Returns the total supply.
        #

        return self.TOTAL_SUPPLY

def approve(approved_add, approved_amount):
        #
        # Allows another account to transfer funds.
        #

        self.allowed[msg.sender][approved_add] = approved_amount

def transferFrom(sending_add, receiving_add, transfer_amount):
        #
        # Transfers funds between accounts.
        #

        result = False
        if self.valid_transfer(sending_add, receiving_add, transfer_amount):
                self.balance[sending_add]   -= transfer_amount
                self.balance[receiving_add] += transfer_amount
                result = True

        return result

def transfer(receiving_add, transfer_amount):
        #
        # Transfers funds between accounts.
        #

        return self.transferFrom(msg.sender, recieving_add, transfer_amount)

def allowance(shared_add, approved_add):
        #
        # Returns the remaining approved amount.
        #

        return self.allowed[shared_add][approved_add]

Conclusion

money

ICOs are a novel way to raise funds and the ETC platform is an excellent choice for the required cryptocurrency smart contracts. Vigilance due to the lack of regulations remains important. Hopefully, mechanisms to protect against abuse will continue to allow an ever growing number of people to benefit from this new method of managing assets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment