Class EthereumServiceImpl

  • All Implemented Interfaces:
    EthereumService

    @Service("ethereumService")
    public class EthereumServiceImpl
    extends java.lang.Object
    implements EthereumService
    Implementation of EthereumService interface Allows you to interact with Ethereum blockchain
    Author:
    Ruslan Nazirov
    • Constructor Detail

      • EthereumServiceImpl

        public EthereumServiceImpl()
    • Method Detail

      • setUp

        public org.web3j.protocol.admin.Admin setUp​(java.lang.String URL)
        Description copied from interface: EthereumService
        Setup Web3j JSON-RPC Request object building factory.
        Specified by:
        setUp in interface EthereumService
        Parameters:
        URL - access URL from Infura (https://infura.io/)
        Returns:
        Admin Web3j JSON-RPC Request object building factory
      • transferEther

        public EtherlinkerResponseData transferEther​(EtherlinkerRequestData etherlinkerRequestData)
                                              throws java.lang.Exception
        Specified by:
        transferEther in interface EthereumService
        Parameters:
        etherlinkerRequestData - request data from compatible application (like UE4)
        Returns:
        EtherlinkerResponseData with transaction result
        Throws:
        java.lang.Exception - any exception, which happened during method execution
      • getBalance

        public EtherlinkerResponseData getBalance​(EtherlinkerRequestData etherlinkerRequestData)
                                           throws java.lang.Exception
        Description copied from interface: EthereumService
        Get balance of specified wallet from request data
        Specified by:
        getBalance in interface EthereumService
        Parameters:
        etherlinkerRequestData - request data from compatible application (like UE4)
        Returns:
        EtherlinkerResponseData response data with a wallet balance
        Throws:
        java.lang.Exception - any exception, which happened during method execution
      • deployContract

        public EtherlinkerResponseData deployContract​(EtherlinkerRequestData etherlinkerRequestData)
                                               throws java.lang.Exception
        Description copied from interface: EthereumService
        Deploy contract, which previously was compiled by Web3j into specific wrapper class
        Specified by:
        deployContract in interface EthereumService
        Parameters:
        etherlinkerRequestData - request data from compatible application (like UE4)
        Returns:
        EtherlinkerResponseData response data with a transaction result
        Throws:
        java.lang.Exception - any exception, which happened during method execution
      • execContractMethod

        public EtherlinkerResponseData execContractMethod​(EtherlinkerRequestData etherlinkerRequestData)
                                                   throws java.lang.Exception
        Description copied from interface: EthereumService
        Execute custom solidity contract method
        Specified by:
        execContractMethod in interface EthereumService
        Parameters:
        etherlinkerRequestData - request data from compatible application (like UE4)
        Returns:
        EtherlinkerResponseData response data with a result of method execution
        Throws:
        java.lang.Exception - any exception, which happened during method execution
      • processBatchRequest

        public EtherlinkerBatchResponseData processBatchRequest​(EtherlinkerBatchRequestData etherlinkerBatchRequestData)
                                                         throws java.lang.Exception
        Description copied from interface: EthereumService
        Execute custom solidity contract method
        Specified by:
        processBatchRequest in interface EthereumService
        Parameters:
        etherlinkerBatchRequestData - batch request data from compatible application (like UE4)
        Returns:
        EtherlinkerBatchResponseData batch response data with a results of method execution
        Throws:
        java.lang.Exception - any exception, which happened during method execution
      • createWallet

        public java.util.ArrayList<java.lang.String> createWallet​(java.lang.String path,
                                                                  java.lang.String password)
                                                           throws java.lang.Exception
        Description copied from interface: EthereumService
        Create a new wallet in a specified directory
        Specified by:
        createWallet in interface EthereumService
        Parameters:
        path - Path to the directory, where you want to the private key
        password - Wallet password
        Returns:
        Wallet filename[0], mnemonic[1] inside of ArrayList
        Throws:
        java.lang.Exception - any exception, which happened during method execution
      • createWallet

        public EtherlinkerResponseData createWallet​(EtherlinkerRequestData etherlinkerRequestData)
                                             throws java.lang.Exception
        Description copied from interface: EthereumService
        Create a new wallet by using request data
        Specified by:
        createWallet in interface EthereumService
        Parameters:
        etherlinkerRequestData - request data from compatible application (like UE4)
        Returns:
        EtherlinkerResponseData response data with a result of method execution
        Throws:
        java.lang.Exception - any exception, which happened during method execution
      • loadWallet

        public org.web3j.crypto.Credentials loadWallet​(java.lang.String password,
                                                       java.lang.String path)
                                                throws java.lang.Exception
        Description copied from interface: EthereumService
        Load wallet credentials by using private key, located in selected path with provided password
        Specified by:
        loadWallet in interface EthereumService
        Parameters:
        password - Wallet password
        path - File system path to the private key
        Returns:
        Wallet Credentials to use in requests to the blockchain
        Throws:
        java.lang.Exception - any exception, which happened during method execution
      • loadWalletBIP39

        public org.web3j.crypto.Credentials loadWalletBIP39​(java.lang.String password,
                                                            java.lang.String mnemonic)
                                                     throws java.lang.Exception
        Description copied from interface: EthereumService
        Load wallet credentials by using provided password and BIP39 mnemonic
        Specified by:
        loadWalletBIP39 in interface EthereumService
        Parameters:
        password - Wallet password
        mnemonic - Wallet mnemonic
        Returns:
        Wallet Credentials to use in requests to the blockchain
        Throws:
        java.lang.Exception - any exception, which happened during method execution
      • fromBIP44HDpath

        public static org.bitcoinj.core.ECKey fromBIP44HDpath​(org.bitcoinj.crypto.DeterministicKey masterKey,
                                                              int accountIndex)
      • enhanceResponseData

        public EtherlinkerResponseData enhanceResponseData​(EtherlinkerResponseData etherlinkerResponseData,
                                                           EtherlinkerRequestData etherlinkerRequestData,
                                                           java.lang.String operationType)
        Description copied from interface: EthereumService
        Enhance response data with parameters, which are common for any type of response
        Specified by:
        enhanceResponseData in interface EthereumService
        Parameters:
        etherlinkerResponseData - half-populated response data to enhance
        etherlinkerRequestData - request data from compatible application (like UE4)
        operationType - Operation type, which was used during method execution (like "createWallet" or "deployContract")
        Returns:
        EtherlinkerResponseData enhanced response data
      • loadCredentials

        public org.web3j.crypto.Credentials loadCredentials​(EtherlinkerRequestData etherlinkerRequestData)
                                                     throws java.lang.Exception
        Description copied from interface: EthereumService
        Load wallet credentials by using provided request data
        Specified by:
        loadCredentials in interface EthereumService
        Parameters:
        etherlinkerRequestData - request data from compatible application (like UE4)
        Returns:
        Wallet Credentials to use in requests to the blockchain
        Throws:
        java.lang.Exception - any exception, which happened during method execution