Esempio n. 1
0
def burn(account: UInt160, amount: int):
    """
    Burns zNEO tokens.

    :param account: the address of the account that is pulling out cryptocurrency of this contract
    :type account: UInt160
    :param amount: the amount of gas to be refunded
    :type amount: int
    :raise AssertionError: raised if `account` length is not 20, amount is less than than 0 or the account doesn't have
    enough zNEO to burn
    """
    assert len(account) == 20
    assert amount >= 0
    if runtime.check_witness(account):
        if amount != 0:
            current_total_supply = total_supply()
            account_balance = balance_of(account)

            assert account_balance >= amount

            storage.put(SUPPLY_KEY, current_total_supply - amount)

            if account_balance == amount:
                storage.delete(account)
            else:
                storage.put(account, account_balance - amount)

            on_transfer(account, None, amount)
            post_transfer(account, None, amount, None, False)

            NEO_TOKEN.transfer(runtime.executing_script_hash, account, amount)
Esempio n. 2
0
def refund(address: UInt160, neo_amount: int, gas_amount: int) -> bool:
    """
    Refunds an address with given Neo and Gas

    :param address: the address that have the tokens
    :type address: UInt160
    :param neo_amount: the amount of neo to be refunded
    :type neo_amount: int
    :param gas_amount: the amount of gas to be refunded
    :type gas_amount: int
    :return: whether the refund was successful
    """
    assert len(address) == 20
    assert neo_amount > 0 or gas_amount > 0

    if not is_administrator():
        return False

    if neo_amount > 0:
        result = NEO_TOKEN.transfer(runtime.calling_script_hash, address,
                                    neo_amount)
        if not result:
            # due to a current limitation in the neo3-boa, changing the condition to `not result`
            # will result in a compiler error
            return False

    if gas_amount > 0:
        result = GAS_TOKEN.transfer(runtime.calling_script_hash, address,
                                    gas_amount)
        if not result:
            # due to a current limitation in the neo3-boa, changing the condition to `not result`
            # will result in a compiler error
            return False

    return True
Esempio n. 3
0
def main(from_address: UInt160, to_address: UInt160) -> int:
    return NEO.transfer(from_address, to_address)
Esempio n. 4
0
def transfer(from_: UInt160, to: UInt160, amount: int) -> bool:
    return NEO.transfer(from_, to, amount)
def main(from_address: UInt160, to_address: UInt160, amount: int, data: Any) -> int:
    return NEO.transfer(from_address, to_address, amount, data, 'arg')