Ejemplo n.º 1
0
def burn(account: UInt160, amount: int):
    """
    Burns zGAS 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 zGAS 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)

            GAS_TOKEN.transfer(runtime.executing_script_hash, account, amount)
Ejemplo 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
Ejemplo n.º 3
0
def main(account: UInt160) -> int:
    return GAS.balanceOf(account)
Ejemplo n.º 4
0
def main() -> str:
    return GAS.symbol()
Ejemplo n.º 5
0
def main(from_address: UInt160, to_address: UInt160, amount: int) -> bool:
    return GAS.transfer(from_address, to_address, amount)
def main() -> int:
    return GAS.totalSupply('arg')
Ejemplo n.º 7
0
def main(account: UInt160) -> int:
    return GAS_CONTRACT.balanceOf(account)
def main(from_address: UInt160, to_address: UInt160, amount: int,
         data: Any) -> bool:
    return GAS.transfer(from_address, to_address, amount, data, 'arg')
def main() -> int:
    return GAS.decimals('arg')
Ejemplo n.º 10
0
def main(from_address: UInt160, to_address: UInt160) -> bool:
    return GAS.transfer(from_address, to_address)