Package com.academy.stratum.service.impl
Class EthereumServiceImpl
- java.lang.Object
-
- com.academy.stratum.service.impl.EthereumServiceImpl
-
- All Implemented Interfaces:
EthereumService
@Service("ethereumService") public class EthereumServiceImpl extends java.lang.Object implements EthereumService
Implementation ofEthereumService
interface Allows you to interact with Ethereum blockchain- Author:
- Ruslan Nazirov
-
-
Constructor Summary
Constructors Constructor Description EthereumServiceImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description EtherlinkerResponseData
createWallet(EtherlinkerRequestData etherlinkerRequestData)
Create a new wallet by using request datajava.util.ArrayList<java.lang.String>
createWallet(java.lang.String path, java.lang.String password)
Create a new wallet in a specified directoryEtherlinkerResponseData
deployContract(EtherlinkerRequestData etherlinkerRequestData)
Deploy contract, which previously was compiled by Web3j into specific wrapper classEtherlinkerResponseData
enhanceResponseData(EtherlinkerResponseData etherlinkerResponseData, EtherlinkerRequestData etherlinkerRequestData, java.lang.String operationType)
Enhance response data with parameters, which are common for any type of responseEtherlinkerResponseData
execContractMethod(EtherlinkerRequestData etherlinkerRequestData)
Execute custom solidity contract methodstatic org.bitcoinj.core.ECKey
fromBIP44HDpath(org.bitcoinj.crypto.DeterministicKey masterKey, int accountIndex)
EtherlinkerResponseData
getBalance(EtherlinkerRequestData etherlinkerRequestData)
Get balance of specified wallet from request dataorg.web3j.crypto.Credentials
loadCredentials(EtherlinkerRequestData etherlinkerRequestData)
Load wallet credentials by using provided request dataorg.web3j.crypto.Credentials
loadWallet(java.lang.String password, java.lang.String path)
Load wallet credentials by using private key, located in selected path with provided passwordorg.web3j.crypto.Credentials
loadWalletBIP39(java.lang.String password, java.lang.String mnemonic)
Load wallet credentials by using provided password and BIP39 mnemonicEtherlinkerBatchResponseData
processBatchRequest(EtherlinkerBatchRequestData etherlinkerBatchRequestData)
Execute custom solidity contract methodorg.web3j.protocol.admin.Admin
setUp(java.lang.String URL)
Setup Web3j JSON-RPC Request object building factory.EtherlinkerResponseData
transferEther(EtherlinkerRequestData etherlinkerRequestData)
-
-
-
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 interfaceEthereumService
- 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 interfaceEthereumService
- 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 interfaceEthereumService
- 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 interfaceEthereumService
- 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 interfaceEthereumService
- 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 interfaceEthereumService
- 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 interfaceEthereumService
- Parameters:
path
- Path to the directory, where you want to the private keypassword
- 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 interfaceEthereumService
- 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 interfaceEthereumService
- Parameters:
password
- Wallet passwordpath
- 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 interfaceEthereumService
- Parameters:
password
- Wallet passwordmnemonic
- 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 interfaceEthereumService
- Parameters:
etherlinkerResponseData
- half-populated response data to enhanceetherlinkerRequestData
- 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 interfaceEthereumService
- 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
-
-