<dependency> <groupId>org.web3j</groupId> <artifactId>core</artifactId> <version>4.8.2</version> </dependency> Web3j web3j = Web3j.build(new HttpService("http://localhost:8545")); EthAccounts accounts = web3j.ethAccounts().send(); List<String> accountList = accounts.getAccounts(); String newAccount = accountList.get(0); EthGetBalance balance = web3j.ethGetBalance(newAccount, DefaultBlockParameterName.LATEST).send(); BigInteger accountBalance = balance.getBalance(); TransactionReceipt transactionReceipt = Transfer.sendFunds( web3j, credentials, toAddress, new BigDecimal("1.0"), Convert.Unit.ETHER).send(); String transactionHash = transactionReceipt.getTransactionHash(); Greeter greeter = Greeter.load(contractAddress, web3j, credentials, GAS_PRICE, GAS_LIMIT); String greeting = greeter.greet().send(); greeter.newGreeting("Hello, Web3j!").send();


上一篇:
下一篇:
切换中文