コード例 #1
0
def post_transfer(from_address: Union[UInt160, None],
                  to_address: Union[UInt160, None], amount: int, data: Any):
    """
    Checks if the one receiving NEP17 tokens is a smart contract and if it's one the onPayment method will be called

    :param from_address: the address of the sender
    :type from_address: UInt160
    :param to_address: the address of the receiver
    :type to_address: UInt160
    :param amount: the amount of cryptocurrency that is being sent
    :type amount: int
    :param data: any pertinent data that might validate the transaction
    :type data: Any
    """
    if to_address is not None:
        contract = ContractManagement.get_contract(to_address)
        if contract is not None:
            call_contract(to_address, 'onNEP17Payment',
                          [from_address, amount, data])
コード例 #2
0
def post_transfer(from_address: Union[UInt160,
                                      None], to_address: Union[UInt160, None],
                  token_id: ByteString, data: Any):
    """
    Checks if the one receiving NEP11 tokens is a smart contract and if it's one the onPayment method will be called.

    :param from_address: the address of the sender
    :type from_address: UInt160
    :param to_address: the address of the receiver
    :type to_address: UInt160
    :param token_id: the id of the token that is being sent
    :type token_id: ByteString
    :param data: any pertinent data that might validate the transaction
    :type data: Any
    """
    # the transfer event will be fired
    on_transfer(from_address, to_address, 1, token_id)

    if not isinstance(to_address, None):
        contract = ContractManagement.get_contract(to_address)
        if not isinstance(contract, None):
            call_contract(to_address, 'onNEP11Payment',
                          [from_address, 1, token_id, data])
コード例 #3
0
def main(hash: UInt160) -> Contract:
    return ContractManagement.get_contract(hash)