Java Code Examples for org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt#getcommitmentHash()

The following examples show how to use org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt#getcommitmentHash() . 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: PrivacyRequestFactory.java    From besu with Apache License 2.0 5 votes vote down vote up
public String privxLockPrivacyGroup(final PrivacyNode locker, final Base64String privacyGroupId)
    throws IOException, TransactionException {
  final BigInteger nonce =
      besuClient
          .privGetTransactionCount(locker.getAddress().toHexString(), privacyGroupId)
          .send()
          .getTransactionCount();

  final RawPrivateTransaction privateTransaction =
      RawPrivateTransaction.createTransaction(
          nonce,
          BigInteger.valueOf(1000),
          BigInteger.valueOf(3000000),
          Address.ONCHAIN_PRIVACY_PROXY.toHexString(),
          OnChainGroupManagement.LOCK_GROUP_METHOD_SIGNATURE.toHexString(),
          Base64String.wrap(locker.getEnclaveKey()),
          privacyGroupId,
          org.web3j.utils.Restriction.RESTRICTED);

  final String transactionHash =
      besuClient
          .eeaSendRawTransaction(
              Numeric.toHexString(
                  PrivateTransactionEncoder.signMessage(
                      privateTransaction, Credentials.create(locker.getTransactionSigningKey()))))
          .send()
          .getTransactionHash();

  final PrivateTransactionReceipt privateTransactionReceipt =
      new PollingPrivateTransactionReceiptProcessor(besuClient, 3000, 10)
          .waitForTransactionReceipt(transactionHash);

  assertThat(privateTransactionReceipt.getStatus()).isEqualTo("0x1");

  return privateTransactionReceipt.getcommitmentHash();
}
 
Example 2
Source File: OnChainPrivacyAcceptanceTest.java    From besu with Apache License 2.0 5 votes vote down vote up
private String getContractDeploymentCommitmentHash(final Contract contract) {
  final Optional<TransactionReceipt> transactionReceipt = contract.getTransactionReceipt();
  assertThat(transactionReceipt).isPresent();
  final PrivateTransactionReceipt privateTransactionReceipt =
      (PrivateTransactionReceipt) transactionReceipt.get();
  return privateTransactionReceipt.getcommitmentHash();
}