Esempio n. 1
0
def Div(a, b):
    """
	Integer division of two numbers, truncating the quotient.
	"""
    Require(b > 0)
    c = a / b
    return c
Esempio n. 2
0
def Add(a, b):
    """
	Adds two numbers, throws on overflow.
	"""
    c = a + b
    Require(c >= a)
    return c
Esempio n. 3
0
def disableInitialStage(addr):
    """
    In case the amassador quota is not met,
    the administrator can manually disable the ambassador phase.

    """
    Require(onlyAdmin(addr))
Esempio n. 4
0
def Sub(a, b):
    """
	Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
    :param a: operand a
    :param b: operand b
    :return: a - b if a - b > 0 or revert the transaction.
	"""
    Require(a >= b)
    return a - b
Esempio n. 5
0
def Mul(a, b):
    """
	Multiplies two numbers, throws on overflow.
    :param a: operand a
    :param b: operand b
    :return: a - b if a - b > 0 or revert the transaction.
	"""
    if a == 0:
        return 0
    c = a * b
    Require(c / a == b)
    return c
Esempio n. 6
0
def buy(account, ongAmount, referredBy):
    """
    Converts all incoming ethereum to tokens for the caller,
    and passes down the referral addy (if any)
    """
    CheckWitness(account)
    _undividedDividends = Div(Mul(ongAmount, dividendFee_), 100)
    _referralBonus = Div(Mul(ongAmount, referralFee_), 100)
    _dividends = Sub(_undividedDividends, _referralBonus)
    _taxedOng = Sub(ongAmount - _undividedDividends)
    _amountOfTokens = OngToToken(_taxedOng)
    Require(_amountOfTokens > 0 & Add(_amountOfTokens, tokenSupply_) > tokenSupply_)
    if(referredBy != 0 &
    referredBy != account &
    tokenBalanceOf(referredBy) >= statingRequirement_):
        i = 0
Esempio n. 7
0
def setSymbol(admin, _symbol):
    Require(onlyAdmin(admin))
    symbol = _symbol
    return True
Esempio n. 8
0
def setName(admin, _name):
    Require(onlyAdmin(admin))
    name = _name
    return True
Esempio n. 9
0
def setStakingRequirement(admin, _amountOfTokens):
    Require(onlyAdmin(admin))
    statingRequirement_ = _amountOfTokens
    Notify("statingRequirement", statingRequirement_)
    return True
Esempio n. 10
0
def deleteAdmin(fromAdmin, deletedAdmin):
    Require(onlyAdmin(fromAdmin, deletedAdmin))
    key = concatKey(ADMIN_PREFIX, deletedAdmin)
    Delete(GetContext(), key)
    Notify(["deleteAdmin", fromAdmin, deletedAdmin])
Esempio n. 11
0
def addAdmin(fromAdmin, newAdmin):
    Require(onlyAdmin(fromAdmin))
    key = concatKey(ADMIN_PREFIX, newAdmin)
    Put(GetContext(), key, True)
    Notify(["addAdmin", fromAdmin, newAdmin])
    return True