public static Web3j generateClient ( String clientAddress , Long timeoutSeconds ) { if ( isEmpty ( clientAddress ) ) { throw new IllegalArgumentException ( "You have to define client address, use constructor or environment variable 'web3j.clientAddress'" ) ; } Web3jService web3jService ; if ( clientAddress . startsWith ( "http" ) ) { web3jService = new HttpService ( clientAddress , createOkHttpClient ( timeoutSeconds ) , false ) ; } else if ( clientAddress . startsWith ( "wss" ) ) { try { web3jService = new WebSocketService ( clientAddress , true ) ; ( ( WebSocketService ) web3jService ) . connect ( ) ; } catch ( Exception ex ) { throw new RuntimeException ( ex ) ; } } else if ( System . getProperty ( "os.name" ) . toLowerCase ( ) . startsWith ( "win" ) ) { web3jService = new WindowsIpcService ( clientAddress ) ; } else { web3jService = new UnixIpcService ( clientAddress ) ; } return Web3j . build ( web3jService ) ; }
Generate Ethereum client .