Package 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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends TransactionResponse>
booleanisDuplicate(T myTransaction, List<T> existingUnconfirmedTransactions) 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".processRequest(RequestContext context) Send the exchange rate in response to a simple API callprocessTransaction(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, processVoucherMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface nxt.addons.Contract
init, minProductVersion, shutdown
-
Constructor Details
-
IgnisArdorRates
public IgnisArdorRates()
-
-
Method Details
-
processBlock
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:
processBlockin interfaceContract<InvocationData,ReturnedData> - Overrides:
processBlockin classAbstractContract<InvocationData,ReturnedData> - Parameters:
context- the block context
-
processTransaction
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:
processTransactionin interfaceContract<InvocationData,ReturnedData> - Overrides:
processTransactionin classAbstractContract<InvocationData,ReturnedData> - Parameters:
context- the transaction context
-
processRequest
Send the exchange rate in response to a simple API call- Specified by:
processRequestin interfaceContract<InvocationData,ReturnedData> - Overrides:
processRequestin classAbstractContract<InvocationData,ReturnedData> - Parameters:
context- the api request context
-
isDuplicate
public <T extends TransactionResponse> boolean isDuplicate(T myTransaction, List<T> existingUnconfirmedTransactions) - Specified by:
isDuplicatein interfaceContract<InvocationData,ReturnedData> - Overrides:
isDuplicatein classAbstractContract<InvocationData,ReturnedData>
-