Java Code Examples for org.web3j.protocol.core.methods.response.TransactionReceipt#getTransactionHash()

The following examples show how to use org.web3j.protocol.core.methods.response.TransactionReceipt#getTransactionHash() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransactionFactory.java    From asf-sdk with GNU General Public License v3.0 6 votes vote down vote up
public static Transaction fromEthGetTransactionReceipt(
    EthGetTransactionReceipt ethGetTransactionReceipt) {
  TransactionReceipt transactionReceipt = ethGetTransactionReceipt.getTransactionReceipt();

  String hash = transactionReceipt.getTransactionHash();
  String from = transactionReceipt.getFrom();
  Log log = transactionReceipt.getLogs()
      .get(0);
  String to = log.getAddress();
  String value = extractValueFromEthGetTransactionReceipt(log.getData());
  Status status = parseStatus(transactionReceipt.getStatus());
  String contractAddress = ethGetTransactionReceipt.getTransactionReceipt()
      .getTo();

  return new Transaction(hash, from, to, value, status);
}
 
Example 2
Source File: EmptyTransactionReceipt.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }
    if (!(o instanceof TransactionReceipt)) {
        return false;
    }

    TransactionReceipt that = (TransactionReceipt) o;

    return getTransactionHash() != null
            ? getTransactionHash().equals(that.getTransactionHash())
            : that.getTransactionHash() == null;
}
 
Example 3
Source File: EmptyTransactionReceipt.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }
    if (!(o instanceof TransactionReceipt)) {
        return false;
    }

    TransactionReceipt that = (TransactionReceipt) o;

    return getTransactionHash() != null
            ? getTransactionHash().equals(that.getTransactionHash())
            : that.getTransactionHash() == null;
}
 
Example 4
Source File: EmptyTransactionReceipt.java    From web3j with Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }
    if (!(o instanceof TransactionReceipt)) {
        return false;
    }

    TransactionReceipt that = (TransactionReceipt) o;

    return getTransactionHash() != null
            ? getTransactionHash().equals(that.getTransactionHash())
            : that.getTransactionHash() == null;
}
 
Example 5
Source File: ContractDemo.java    From web3j_demo with Apache License 2.0 4 votes vote down vote up
private Greeter deployContract() throws Exception {
	System.out.println("// Deploy contract Greeter");

	Greeter contract = Greeter
			.deploy(
					web3j, 
					Alice.CREDENTIALS, 
					Web3jConstants.GAS_PRICE, 
					Web3jConstants.GAS_LIMIT_GREETER_TX, 
					BigInteger.ZERO, 
					new Utf8String("hello world"))
			.get();

	// get tx receipt
	TransactionReceipt txReceipt = contract
			.getTransactionReceipt()
			.get();

	// get tx hash and tx fees
	String deployHash = txReceipt.getTransactionHash();
	BigInteger deployFees = txReceipt
			.getCumulativeGasUsed()
			.multiply(Web3jConstants.GAS_PRICE);

	System.out.println("Deploy hash: " + deployHash);
	System.out.println("Deploy fees: " + Web3jUtils.weiToEther(deployFees));

	// get initial contract balance
	Uint256 deposits = contract
			.deposits()
			.get();

	String contractAddress = contract.getContractAddress();
	System.out.println("Contract address: " + contractAddress);
	System.out.println("Contract address balance (initial): " + Web3jUtils.getBalanceWei(web3j, contractAddress));
	System.out.println("Contract.deposits(): " + deposits.getValue());
	printBalanceAlice("after deploy");
	System.out.println();

	return contract;
}