use of org.bcos.web3j.protocol.Web3j in project web3sdk by FISCO-BCOS.
the class WalletSendFunds method run.
private void run(String walletFileLocation, String destinationAddress) {
File walletFile = new File(walletFileLocation);
Credentials credentials = getCredentials(walletFile);
console.printf("Wallet for address " + credentials.getAddress() + " loaded\n");
if (!WalletUtils.isValidAddress(destinationAddress)) {
exitError("Invalid destination address specified");
}
Web3j web3j = getEthereumClient();
BigDecimal amountToTransfer = getAmountToTransfer();
Convert.Unit transferUnit = getTransferUnit();
BigDecimal amountInWei = Convert.toWei(amountToTransfer, transferUnit);
confirmTransfer(amountToTransfer, transferUnit, amountInWei, destinationAddress);
TransactionReceipt transactionReceipt = performTransfer(web3j, destinationAddress, credentials, amountInWei);
console.printf("Funds have been successfully transferred from %s to %s%n" + "Transaction hash: %s%nMined block number: %s%n", credentials.getAddress(), destinationAddress, transactionReceipt.getTransactionHash(), transactionReceipt.getBlockNumber());
}
Aggregations