Interface TransactionService
- All Known Implementing Classes:
TransactionServiceImpl
public interface TransactionService
-
Method Summary
Modifier and Type Method Description io.reactivex.Single<StringResultWrapper>
asyncCreateUnsignedTransaction(AbstractTransactionModel<?> tx)
asynchronously creates an unsignedTx object for further processing and especially abstracts the fee calculation for this transactionio.reactivex.Single<DryRunTransactionResults>
asyncDryRunTransactions(DryRunRequest input)
asynchronously dry run unsigned transactions to estimate gas (!) please make sure to use implementations ofList
to ensure correct order of transactions called by accountsio.reactivex.Single<PostTransactionResult>
asyncPostTransaction(AbstractTransactionModel<?> tx)
asynchronously post a transaction for given model with the private key stored in the configurationio.reactivex.Single<PostTransactionResult>
asyncPostTransaction(AbstractTransactionModel<?> tx, java.lang.String privateKey)
asynchronously post a transaction for given modelio.reactivex.Single<PostTransactionResult>
asyncPostTransaction(java.lang.String signedTx)
asynchronously post a transaction based on the given signedTx as Stringio.reactivex.Single<TransactionResult>
asyncWaitForConfirmation(java.lang.String txHash)
asynchronously wait for a transaction to be confirmedio.reactivex.Single<TransactionResult>
asyncWaitForConfirmation(java.lang.String txHash, int numOfConfirmations)
asynchronously wait for a transaction to be confirmedCheckTxInPoolResult
blockingCheckTxInPool(java.lang.String txHash)
ContractTxResult
blockingContractCreate(java.lang.String sourceCode)
convenience method to deploy a contract and return the tx-hash along with the decoded result and other useful information related to the tx.ContractTxResult
blockingContractCreate(java.lang.String sourceCode, ContractTxOptions txOptions)
convenience method to deploy a contract and return the tx-hash along with the decoded result and other useful information related to the tx.StringResultWrapper
blockingCreateUnsignedTransaction(AbstractTransactionModel<?> tx)
synchronously creates an unsignedTx object for further processing and especially abstracts the fee calculation for this transactionDryRunTransactionResult
blockingDryRunContractTx(AbstractTransactionModel<?> contractTx, boolean useZeroAddress)
convenience function to perform a dry-run for a single tx by providing one ofAbstractTransaction
DryRunTransactionResults
blockingDryRunTransactions(DryRunRequest input)
synchronously dry run unsigned transactions to estimate gas (!) please make sure to use implementations ofList
to ensure correct order of transactions called by accountsPostTransactionResult
blockingPostTransaction(AbstractTransactionModel<?> tx)
synchronously post a transaction for given model with the private key stored in the configurationPostTransactionResult
blockingPostTransaction(AbstractTransactionModel<?> tx, java.lang.String privateKey)
synchronously post a transaction for given modelPostTransactionResult
blockingPostTransaction(java.lang.String signedTx)
synchronously post a transaction based on the given signedTx as Stringjava.lang.Object
blockingReadOnlyContractCall(java.lang.String contractId, java.lang.String entrypoint, java.lang.String sourceCode)
convenience method to perform a read-only contract call and return the decoded call result.java.lang.Object
blockingReadOnlyContractCall(java.lang.String contractId, java.lang.String entrypoint, java.lang.String sourceCode, ContractTxOptions txOptions)
convenience method to perform a read-only contract call and return the decoded call result.ContractTxResult
blockingStatefulContractCall(java.lang.String contractId, java.lang.String entrypoint, java.lang.String sourceCode)
convenience method to perform a stateful contract call and return the tx-hash along with the decoded result and other useful information related to the tx.ContractTxResult
blockingStatefulContractCall(java.lang.String contractId, java.lang.String entrypoint, java.lang.String sourceCode, ContractTxOptions txOptions)
convenience method to perform a stateful contract call and return the tx-hash along with the decoded result and other useful information related to the tx.java.lang.String
computeGAInnerTxHash(AbstractTransactionModel<?> tx)
synchronously creates an unsigned transaction out of the given AbstractTransactionModel and append network data to the resulting byte array.java.lang.String
computeTxHash(AbstractTransactionModel<?> tx)
[@PURPOSE-DEBUG] synchronously compute the transaction hash for the given transaction modeljava.lang.String
signPayingForInnerTransaction(AbstractTransactionModel<?> model, java.lang.String privateKey)
sign an unsigned transaction with the given private key.java.lang.String
signTransaction(java.lang.String unsignedTx, java.lang.String privateKey)
sign an unsigned transaction with the given private key
-
Method Details
-
signTransaction
java.lang.String signTransaction(java.lang.String unsignedTx, java.lang.String privateKey) throws TransactionCreateExceptionsign an unsigned transaction with the given private key- Parameters:
unsignedTx
- the encoded unsigned transactionprivateKey
- the encoded private key to sign the transaction- Returns:
- signed and encoded transaction
- Throws:
TransactionCreateException
- if an error occurs
-
asyncCreateUnsignedTransaction
io.reactivex.Single<StringResultWrapper> asyncCreateUnsignedTransaction(AbstractTransactionModel<?> tx)asynchronously creates an unsignedTx object for further processing and especially abstracts the fee calculation for this transaction- Parameters:
tx
- transaction typed model, one ofAbstractTransaction
- Returns:
- a single-wrapped unsignedTx object
-
blockingCreateUnsignedTransaction
synchronously creates an unsignedTx object for further processing and especially abstracts the fee calculation for this transaction- Parameters:
tx
- transaction typed model, one ofAbstractTransaction
- Returns:
- a single-wrapped unsignedTx object
-
asyncDryRunTransactions
asynchronously dry run unsigned transactions to estimate gas (!) please make sure to use implementations ofList
to ensure correct order of transactions called by accounts- Parameters:
input
-DryRunRequest
object- Returns:
- asynchronous result handler (RxJava Single) for
DryRunTransactionResults
-
blockingDryRunContractTx
DryRunTransactionResult blockingDryRunContractTx(AbstractTransactionModel<?> contractTx, boolean useZeroAddress)convenience function to perform a dry-run for a single tx by providing one ofAbstractTransaction
using the zeroAddress for the dry-run MUST be used if no KeyPair is provided in the
ServiceConfiguration
- Parameters:
contractTx
- must be of typeContractCreateTransactionModel
orContractCallTransactionModel
useZeroAddress
- true to use the zero address which makes sense for a non-stateful (ready-only) contract call, false if account in configuration should be used to simulate a stateful tx- Returns:
- instance of
DryRunTransactionResult
if call was successful, otherwise throwsAException
-
blockingDryRunTransactions
synchronously dry run unsigned transactions to estimate gas (!) please make sure to use implementations ofList
to ensure correct order of transactions called by accounts- Parameters:
input
- instance ofDryRunRequest
- Returns:
- instance of
DryRunTransactionResults
-
blockingContractCreate
convenience method to deploy a contract and return the tx-hash along with the decoded result and other useful information related to the tx. performs following steps under the hood: 1. generate bytecode via compiler, 2. encode calldata via compiler, 3. sign and broadcast the ContractCreateTx with the keyPair configured in theServiceConfiguration
, 4. wait for the tx to be included in a microblock, 5. fetch the tx-info from node, 6. decode result calldata via compiler, 7. return theContractTxResult
- Parameters:
sourceCode
- the source code of the contracttxOptions
- custom tx-options as defined in theContractTxOptions
class- Returns:
- the result of the contract creation (deployment) including the tx-hash and other useful information related to the tx
-
blockingContractCreate
convenience method to deploy a contract and return the tx-hash along with the decoded result and other useful information related to the tx. performs following steps under the hood: 1. generate bytecode via compiler, 2. encode calldata via compiler, 3. sign and broadcast the ContractCreateTx with the keyPair configured in theServiceConfiguration
, 4. wait for the tx to be included in a microblock, 5. fetch the tx-info from node, 6. decode result calldata via compiler, 7. return theContractTxResult
- Parameters:
sourceCode
- the source code of the contract- Returns:
- the result of the contract creation (deployment) including the tx-hash and other useful information related to the tx
-
blockingReadOnlyContractCall
java.lang.Object blockingReadOnlyContractCall(java.lang.String contractId, java.lang.String entrypoint, java.lang.String sourceCode, ContractTxOptions txOptions)convenience method to perform a read-only contract call and return the decoded call result. performs following steps under the hood: 1. encode calldata via compiler, 2. dry-run the contract call via node, 3. decode result calldata via compiler- Parameters:
contractId
- the id of the contract (ct_...)entrypoint
- the name of the entrypointsourceCode
- the source code of the contracttxOptions
- custom tx-options as defined in theContractTxOptions
class. only the attributes "params" and "filesystem" are relevant here. other attributes will be ignored- Returns:
- the decoded rawResult as String
-
blockingReadOnlyContractCall
java.lang.Object blockingReadOnlyContractCall(java.lang.String contractId, java.lang.String entrypoint, java.lang.String sourceCode)convenience method to perform a read-only contract call and return the decoded call result. performs following steps under the hood: 1. encode calldata via compiler, 2. dry-run the contract call via node, 3. decode result calldata via compiler- Parameters:
contractId
- the id of the contract (ct_...)entrypoint
- the name of the entrypointsourceCode
- the source code of the contract- Returns:
- the decoded rawResult as String
-
blockingStatefulContractCall
ContractTxResult blockingStatefulContractCall(java.lang.String contractId, java.lang.String entrypoint, java.lang.String sourceCode, ContractTxOptions txOptions)convenience method to perform a stateful contract call and return the tx-hash along with the decoded result and other useful information related to the tx. performs following steps under the hood: 1. encode calldata via compiler, 2. sign and broadcast the ContractCallTx with the keyPair configured in theServiceConfiguration
, 3. wait for the tx to be included in a microblock, 4. fetch the tx-info from node, 5. decode result calldata via compiler, 6. return theContractTxResult
- Parameters:
contractId
- the id of the contract (ct_...)entrypoint
- the name of the entrypointsourceCode
- the source code of the contracttxOptions
- custom tx-options as defined in theContractTxOptions
class- Returns:
- the result of the contract call including the tx-hash and other useful information related to the tx
-
blockingStatefulContractCall
ContractTxResult blockingStatefulContractCall(java.lang.String contractId, java.lang.String entrypoint, java.lang.String sourceCode)convenience method to perform a stateful contract call and return the tx-hash along with the decoded result and other useful information related to the tx. performs following steps under the hood: 1. encode calldata via compiler, 2. sign and broadcast the ContractCallTx with the keyPair configured in theServiceConfiguration
, 3. wait for the tx to be included in a microblock, 4. fetch the tx-info from node, 5. decode result calldata via compiler, 6. return theContractTxResult
- Parameters:
contractId
- the id of the contract (ct_...)entrypoint
- the name of the entrypointsourceCode
- the source code of the contract- Returns:
- the result of the contract call including the tx-hash and other useful information related to the tx
-
asyncPostTransaction
io.reactivex.Single<PostTransactionResult> asyncPostTransaction(AbstractTransactionModel<?> tx, java.lang.String privateKey)asynchronously post a transaction for given model- Parameters:
tx
- instance of a specific TransactionModel-class that extendsAbstractTransactionModel
privateKey
- the privateKey to sign the tx- Returns:
- asynchronous result handler (RxJava Single) for
PostTransactionResult
-
asyncPostTransaction
asynchronously post a transaction for given model with the private key stored in the configuration- Parameters:
tx
- instance of a specific TransactionModel-class that extendsAbstractTransactionModel
- Returns:
- asynchronous result handler (RxJava Single) for
PostTransactionResult
-
blockingPostTransaction
PostTransactionResult blockingPostTransaction(AbstractTransactionModel<?> tx, java.lang.String privateKey)synchronously post a transaction for given model- Parameters:
tx
- instance of a specific TransactionModel-class that extendsAbstractTransactionModel
privateKey
- the privateKey to sign the tx- Returns:
- instance of
PostTransactionResult
-
blockingPostTransaction
synchronously post a transaction for given model with the private key stored in the configuration- Parameters:
tx
- instance of a specific TransactionModel-class that extendsAbstractTransactionModel
- Returns:
- instance of
PostTransactionResult
-
computeTxHash
[@PURPOSE-DEBUG] synchronously compute the transaction hash for the given transaction model- Parameters:
tx
- instance of a specific TransactionModel-class that extendsAbstractTransactionModel
- Returns:
- the hash from a signed and encoded transaction
- Throws:
TransactionCreateException
- if an error occurs
-
blockingPostTransaction
synchronously post a transaction based on the given signedTx as String- Parameters:
signedTx
- a signed and encoded transaction- Returns:
- instance of
PostTransactionResult
-
asyncPostTransaction
asynchronously post a transaction based on the given signedTx as String- Parameters:
signedTx
- a signed and encoded transaction- Returns:
- asynchronous result handler (RxJava Single) for
PostTransactionResult
-
asyncWaitForConfirmation
asynchronously wait for a transaction to be confirmedthe number of keyblocks to consider the transaction confirmed is defined in the property numOfConfirmations of the
AeternityServiceConfiguration
(default 10)- Parameters:
txHash
- the tx-hash of the transaction to be confirmed- Returns:
- the actual
TransactionResult
of the transaction at the confirmation heightNote:
- check getRootErrorMessage(): if a rootErrorMessage is present the transaction is probably not mined.
- check getBlockHeight(): if the blockHeight is -1 it means the transaction isn't mined.
-
asyncWaitForConfirmation
io.reactivex.Single<TransactionResult> asyncWaitForConfirmation(java.lang.String txHash, int numOfConfirmations)asynchronously wait for a transaction to be confirmed- Parameters:
txHash
- the tx-hash of the transaction to be confirmednumOfConfirmations
- the amount of keyblocks required to consider a transaction to be confirmed/mined- Returns:
- the actual
TransactionResult
of the transaction at the confirmation heightNote: @Override
- check getRootErrorMessage(): if a rootErrorMessage is present the transaction is probably not mined.
- check getBlockHeight():if the blockHeight is -1 it means the transaction isn't mined.
-
signPayingForInnerTransaction
java.lang.String signPayingForInnerTransaction(AbstractTransactionModel<?> model, java.lang.String privateKey) throws TransactionCreateExceptionsign an unsigned transaction with the given private key. method uses an additional prefix and must be used to sign inner transactions of PayingForTx- Parameters:
model
- of the inner tx to be signedprivateKey
- the encoded private key to sign the transaction- Returns:
- signed and encoded transaction
- Throws:
TransactionCreateException
- if an error occurs
-
computeGAInnerTxHash
java.lang.String computeGAInnerTxHash(AbstractTransactionModel<?> tx) throws TransactionCreateExceptionsynchronously creates an unsigned transaction out of the given AbstractTransactionModel and append network data to the resulting byte array. This hash is intended to be used for generalized accounts which provide their own authentication mechanism- Parameters:
tx
- instance of a specific TransactionModel-class that extendsAbstractTransactionModel
- Returns:
- hash of created unsigned transaction appended with network data
- Throws:
TransactionCreateException
-
blockingCheckTxInPool
- Parameters:
txHash
- the tx-hash of the transaction to be confirmed- Returns:
- info if tx can be included by miners or if it is blocked for some reason
-