com.jelurida.ardor.contracts

## Class IgnisArdorRates<InvocationData,ReturnedData>

- java.lang.Object
- - nxt.addons.AbstractContract<InvocationData,ReturnedData>
  - - com.jelurida.ardor.contracts.IgnisArdorRates<InvocationData,ReturnedData>

- All Implemented Interfaces:
    Contract<InvocationData,ReturnedData>

      public class IgnisArdorRates<InvocationData,ReturnedData>
      extends AbstractContract<InvocationData,ReturnedData>

  This sample Oracle contract loads the Ignis per Ardor exchange rate from Bittrex and from the internal coin exchange. It can be used to identify arbitrage opportunities. The contract demonstrates interface with an external service (Bittrex exchange) and how to send a different response when triggered by block, by transaction, by API call. Since the contract interfaces with an external class which loads the exchange rates, it has to be bundled and deployed as a Jar file together with its dependencies to the blockchain.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `IgnisArdorRates.Params`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `IgnisArdorRates()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T extends TransactionResponse> boolean` | `isDuplicate(T myTransaction, java.util.List<T> existingUnconfirmedTransactions)`
    `JO` | `processBlock(BlockContext context)` Write the Ignis per Ardor exchange rate to an account property every pre-defined number of blocks defined by the contract parameter "frequency".
    `JO` | `processRequest(RequestContext context)` Send the exchange rate in response to a simple API call
    `JO` | `processTransaction(TransactionContext context)` Send the Ignis per Ardor exchange rate as an encrypted message back to the sender of the trigger transaction.

    - ### Methods inherited from class nxt.addons.AbstractContract

      `processInvocation, processVoucher`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface nxt.addons.Contract

      `minProductVersion`

- - ### Constructor Detail

    - #### IgnisArdorRates

          public IgnisArdorRates()

  - ### Method Detail

    - #### processBlock

          public JO processBlock(BlockContext context)

      Write the Ignis per Ardor exchange rate to an account property every pre-defined number of blocks defined by the contract parameter "frequency".
      Specified by:
        `processBlock` in interface `Contract<InvocationData,ReturnedData>`
      Overrides:
        `processBlock` in class `AbstractContract<InvocationData,ReturnedData>`
      Parameters:
        `context` - the block context

    - #### processTransaction

          public JO processTransaction(TransactionContext context)

      Send the Ignis per Ardor exchange rate as an encrypted message back to the sender of the trigger transaction. Note an example of sending encrypted message from the contract account to the trigger transaction sender.
      Specified by:
        `processTransaction` in interface `Contract<InvocationData,ReturnedData>`
      Overrides:
        `processTransaction` in class `AbstractContract<InvocationData,ReturnedData>`
      Parameters:
        `context` - the transaction context

    - #### processRequest

          public JO processRequest(RequestContext context)

      Send the exchange rate in response to a simple API call
      Specified by:
        `processRequest` in interface `Contract<InvocationData,ReturnedData>`
      Overrides:
        `processRequest` in class `AbstractContract<InvocationData,ReturnedData>`
      Parameters:
        `context` - the api request context

    - #### isDuplicate

          public <T extends TransactionResponse> boolean isDuplicate(T myTransaction,
                                                                     java.util.List<T> existingUnconfirmedTransactions)

      Specified by:
        `isDuplicate` in interface `Contract<InvocationData,ReturnedData>`
      Overrides:
        `isDuplicate` in class `AbstractContract<InvocationData,ReturnedData>`