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 EthereumServiceImplementation ofEthereumServiceinterface 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 EtherlinkerResponseDatacreateWallet(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 directoryEtherlinkerResponseDatadeployContract(EtherlinkerRequestData etherlinkerRequestData)Deploy contract, which previously was compiled by Web3j into specific wrapper classEtherlinkerResponseDataenhanceResponseData(EtherlinkerResponseData etherlinkerResponseData, EtherlinkerRequestData etherlinkerRequestData, java.lang.String operationType)Enhance response data with parameters, which are common for any type of responseEtherlinkerResponseDataexecContractMethod(EtherlinkerRequestData etherlinkerRequestData)Execute custom solidity contract methodstatic org.bitcoinj.core.ECKeyfromBIP44HDpath(org.bitcoinj.crypto.DeterministicKey masterKey, int accountIndex)EtherlinkerResponseDatagetBalance(EtherlinkerRequestData etherlinkerRequestData)Get balance of specified wallet from request dataorg.web3j.crypto.CredentialsloadCredentials(EtherlinkerRequestData etherlinkerRequestData)Load wallet credentials by using provided request dataorg.web3j.crypto.CredentialsloadWallet(java.lang.String password, java.lang.String path)Load wallet credentials by using private key, located in selected path with provided passwordorg.web3j.crypto.CredentialsloadWalletBIP39(java.lang.String password, java.lang.String mnemonic)Load wallet credentials by using provided password and BIP39 mnemonicEtherlinkerBatchResponseDataprocessBatchRequest(EtherlinkerBatchRequestData etherlinkerBatchRequestData)Execute custom solidity contract methodorg.web3j.protocol.admin.AdminsetUp(java.lang.String URL)Setup Web3j JSON-RPC Request object building factory.EtherlinkerResponseDatatransferEther(EtherlinkerRequestData etherlinkerRequestData)
-
-
-
Method Detail
-
setUp
public org.web3j.protocol.admin.Admin setUp(java.lang.String URL)
Description copied from interface:EthereumServiceSetup Web3j JSON-RPC Request object building factory.- Specified by:
setUpin 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:
transferEtherin 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:EthereumServiceGet balance of specified wallet from request data- Specified by:
getBalancein 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:EthereumServiceDeploy contract, which previously was compiled by Web3j into specific wrapper class- Specified by:
deployContractin 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:EthereumServiceExecute custom solidity contract method- Specified by:
execContractMethodin 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:EthereumServiceExecute custom solidity contract method- Specified by:
processBatchRequestin 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.ExceptionDescription copied from interface:EthereumServiceCreate a new wallet in a specified directory- Specified by:
createWalletin 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:EthereumServiceCreate a new wallet by using request data- Specified by:
createWalletin 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.ExceptionDescription copied from interface:EthereumServiceLoad wallet credentials by using private key, located in selected path with provided password- Specified by:
loadWalletin interfaceEthereumService- Parameters:
password- Wallet passwordpath- File system path to the private key- Returns:
- Wallet
Credentialsto 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.ExceptionDescription copied from interface:EthereumServiceLoad wallet credentials by using provided password and BIP39 mnemonic- Specified by:
loadWalletBIP39in interfaceEthereumService- Parameters:
password- Wallet passwordmnemonic- Wallet mnemonic- Returns:
- Wallet
Credentialsto 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:EthereumServiceEnhance response data with parameters, which are common for any type of response- Specified by:
enhanceResponseDatain 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:EthereumServiceLoad wallet credentials by using provided request data- Specified by:
loadCredentialsin interfaceEthereumService- Parameters:
etherlinkerRequestData- request data from compatible application (like UE4)- Returns:
- Wallet
Credentialsto use in requests to the blockchain - Throws:
java.lang.Exception- any exception, which happened during method execution
-
-