Interface TransactionService

All Known Implementing Classes:
TransactionServiceImpl

public interface TransactionService
  • Method Details

    • signTransaction

      java.lang.String signTransaction​(java.lang.String unsignedTx, java.lang.String privateKey) throws TransactionCreateException
      sign an unsigned transaction with the given private key
      Parameters:
      unsignedTx - the encoded unsigned transaction
      privateKey - 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 of AbstractTransaction
      Returns:
      a single-wrapped unsignedTx object
    • blockingCreateUnsignedTransaction

      StringResultWrapper blockingCreateUnsignedTransaction​(AbstractTransactionModel<?> tx)
      synchronously creates an unsignedTx object for further processing and especially abstracts the fee calculation for this transaction
      Parameters:
      tx - transaction typed model, one of AbstractTransaction
      Returns:
      a single-wrapped unsignedTx object
    • asyncDryRunTransactions

      io.reactivex.Single<DryRunTransactionResults> asyncDryRunTransactions​(DryRunRequest input)
      asynchronously dry run unsigned transactions to estimate gas (!) please make sure to use implementations of List 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 of AbstractTransaction

      using the zeroAddress for the dry-run MUST be used if no KeyPair is provided in the ServiceConfiguration

      Parameters:
      contractTx - must be of type ContractCreateTransactionModel or ContractCallTransactionModel
      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 throws AException
    • blockingDryRunTransactions

      DryRunTransactionResults blockingDryRunTransactions​(DryRunRequest input)
      synchronously dry run unsigned transactions to estimate gas (!) please make sure to use implementations of List to ensure correct order of transactions called by accounts
      Parameters:
      input - instance of DryRunRequest
      Returns:
      instance of DryRunTransactionResults
    • blockingContractCreate

      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. 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 the ServiceConfiguration, 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 the ContractTxResult
      Parameters:
      sourceCode - the source code of the contract
      txOptions - custom tx-options as defined in the ContractTxOptions class
      Returns:
      the result of the contract creation (deployment) including the tx-hash and other useful information related to the tx
    • blockingContractCreate

      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. 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 the ServiceConfiguration, 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 the ContractTxResult
      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 entrypoint
      sourceCode - the source code of the contract
      txOptions - custom tx-options as defined in the ContractTxOptions 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 entrypoint
      sourceCode - 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 the ServiceConfiguration, 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 the ContractTxResult
      Parameters:
      contractId - the id of the contract (ct_...)
      entrypoint - the name of the entrypoint
      sourceCode - the source code of the contract
      txOptions - custom tx-options as defined in the ContractTxOptions 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 the ServiceConfiguration, 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 the ContractTxResult
      Parameters:
      contractId - the id of the contract (ct_...)
      entrypoint - the name of the entrypoint
      sourceCode - 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 extends AbstractTransactionModel
      privateKey - the privateKey to sign the tx
      Returns:
      asynchronous result handler (RxJava Single) for PostTransactionResult
    • asyncPostTransaction

      io.reactivex.Single<PostTransactionResult> asyncPostTransaction​(AbstractTransactionModel<?> tx)
      asynchronously post a transaction for given model with the private key stored in the configuration
      Parameters:
      tx - instance of a specific TransactionModel-class that extends AbstractTransactionModel
      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 extends AbstractTransactionModel
      privateKey - the privateKey to sign the tx
      Returns:
      instance of PostTransactionResult
    • blockingPostTransaction

      PostTransactionResult blockingPostTransaction​(AbstractTransactionModel<?> tx)
      synchronously post a transaction for given model with the private key stored in the configuration
      Parameters:
      tx - instance of a specific TransactionModel-class that extends AbstractTransactionModel
      Returns:
      instance of PostTransactionResult
    • computeTxHash

      java.lang.String computeTxHash​(AbstractTransactionModel<?> tx) throws TransactionCreateException
      [@PURPOSE-DEBUG] synchronously compute the transaction hash for the given transaction model
      Parameters:
      tx - instance of a specific TransactionModel-class that extends AbstractTransactionModel
      Returns:
      the hash from a signed and encoded transaction
      Throws:
      TransactionCreateException - if an error occurs
    • blockingPostTransaction

      PostTransactionResult blockingPostTransaction​(java.lang.String signedTx)
      synchronously post a transaction based on the given signedTx as String
      Parameters:
      signedTx - a signed and encoded transaction
      Returns:
      instance of PostTransactionResult
    • asyncPostTransaction

      io.reactivex.Single<PostTransactionResult> asyncPostTransaction​(java.lang.String signedTx)
      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

      io.reactivex.Single<TransactionResult> asyncWaitForConfirmation​(java.lang.String txHash)
      asynchronously wait for a transaction to be confirmed

      the 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 height

      Note:

      - 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 confirmed
      numOfConfirmations - the amount of keyblocks required to consider a transaction to be confirmed/mined
      Returns:
      the actual TransactionResult of the transaction at the confirmation height

      Note: @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 TransactionCreateException
      sign 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 signed
      privateKey - 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 TransactionCreateException
      synchronously 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 extends AbstractTransactionModel
      Returns:
      hash of created unsigned transaction appended with network data
      Throws:
      TransactionCreateException
    • blockingCheckTxInPool

      CheckTxInPoolResult blockingCheckTxInPool​(java.lang.String txHash)
      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