コード例 #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)
コード例 #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
コード例 #3
0
def main() -> int:
    return NEO.decimals('arg')
コード例 #4
0
def main() -> List[Tuple[Any, Any]]:
    return NEO.get_candidates()
コード例 #5
0
def main(account: UInt160) -> NeoAccountState:
    return NEO.get_account_state(account)
コード例 #6
0
def main() -> int:
    return NEO.totalSupply('arg')
コード例 #7
0
def main(account: UInt160) -> int:
    return NEO.balanceOf(account, 'arg')
コード例 #8
0
def main() -> str:
    return NEO.symbol('arg')
コード例 #9
0
def main() -> List[ECPoint]:
    return NEO.get_next_block_validators()
コード例 #10
0
def main(from_address: UInt160, to_address: UInt160) -> int:
    return NEO.transfer(from_address, to_address)
コード例 #11
0
def main(account: UInt160, index: int) -> int:
    return NEO.unclaimed_gas(account, index)
コード例 #12
0
def main() -> List[ECPoint]:
    return NEO.get_committee()
コード例 #13
0
ファイル: Vote.py プロジェクト: CityOfZion/neo3-boa
def main(account: UInt160, pubkey: ECPoint) -> bool:
    return NEO.vote(account, pubkey)
コード例 #14
0
def main(from_address: UInt160, to_address: UInt160, amount: int, data: Any) -> int:
    return NEO.transfer(from_address, to_address, amount, data, 'arg')
コード例 #15
0
def main(pubkey: ECPoint) -> bool:
    return NEO.register_candidate(pubkey)
コード例 #16
0
def transfer(from_: UInt160, to: UInt160, amount: int) -> bool:
    return NEO.transfer(from_, to, amount)
コード例 #17
0
ファイル: GetGasPerBlock.py プロジェクト: CityOfZion/neo3-boa
def main() -> int:
    return NEO.get_gas_per_block()