groovy dependencies { implementation 'org.web3j:core:5.0.0' } Web3j web3j = Web3j.build(new HttpService("https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID")); EthGetBalance balance = web3j.ethGetBalance("0xYourEthereumAddress", DefaultBlockParameterName.LATEST).send(); BigInteger accountBalance = balance.getBalance(); System.out.println("Account balance: " + accountBalance); Credentials credentials = WalletUtils.loadCredentials("password", "/path/to/walletfile"); TransactionReceipt transactionReceipt = Transfer.sendFunds( web3j, credentials, "0xrecipientAddress", BigDecimal.valueOf(1.0), Convert.Unit.ETHER) .send(); String transactionHash = transactionReceipt.getTransactionHash(); System.out.println("Transaction hash: " + transactionHash);


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