Class ContractFunctionResult

java.lang.Object
com.hedera.hashgraph.sdk.ContractFunctionResult

public final class ContractFunctionResult extends Object
Result of invoking a contract via ContractCallQuery, or ContractExecuteTransaction, or the result of a contract constructor being called by ContractCreateTransaction.

If you require a type which is not supported here, please let us know on this Github issue.

  • Field Details

    • contractId

      public final ContractId contractId
      The ID of the contract that was invoked.
    • evmAddress

      @Nullable public final ContractId evmAddress
      The contract's 20-byte EVM address
    • errorMessage

      @Nullable public final String errorMessage
      message in case there was an error during smart contract execution
    • bloom

      public final com.google.protobuf.ByteString bloom
      bloom filter for record
    • gasUsed

      public final long gasUsed
      units of gas used to execute contract
    • logs

      public final List<ContractLogInfo> logs
      the log info for events returned by the function
    • createdContractIds

      @Deprecated public final List<ContractId> createdContractIds
      Deprecated.
      The created ids will now _also_ be externalized through internal transaction records, where each record has its alias field populated with the new contract's EVM address. (This is needed for contracts created with CREATE2, since there is no longer a simple relationship between the new contract's 0.0.X id and its Solidity address.)
    • stateChanges

      @Deprecated public final List<ContractStateChange> stateChanges
      Deprecated.
      - Use mirror node for contract traceability instead
    • gas

      public final long gas
      The amount of gas available for the call, aka the gasLimit
    • hbarAmount

      public final Hbar hbarAmount
      Number of tinybars sent (the function must be payable if this is nonzero).
    • contractFunctionParametersBytes

      public final byte[] contractFunctionParametersBytes
      The parameters passed into the contract call.
      This field should only be populated when the paired TransactionBody in the record stream is not a ContractCreateTransactionBody or a ContractCallTransactionBody.
    • senderAccountId

      @Nullable public final AccountId senderAccountId
      The account that is the "sender." If not present it is the accountId from the transactionId.
    • contractNonces

      public final List<ContractNonceInfo> contractNonces
      A list of updated contract account nonces containing the new nonce value for each contract account. This is always empty in a ContractCallLocalResponse#ContractFunctionResult message, since no internal creations can happen in a static EVM call.
    • signerNonce

      public final long signerNonce
      If not null this field specifies what the value of the signer account nonce is post transaction execution. For transactions that don't update the signer nonce (like HAPI ContractCall and ContractCreate transactions) this field should be null.
  • Constructor Details

  • Method Details

    • asBytes

      public byte[] asBytes()
      Get the whole raw function result.
      Returns:
      byte[]
    • getString

      public String getString(int valIndex)
      Get the nth returned value as a string
      Parameters:
      valIndex - The index of the string to be retrieved
      Returns:
      String
    • getStringArray

      public List<String> getStringArray(int index)
      Get the nth returned value as a list of strings
      Parameters:
      index - The index of the list of strings to be retrieved
      Returns:
      A List of Strings
    • getBytes

      public byte[] getBytes(int valIndex)
      Get the nth value in the result as a dynamic byte array.
      Parameters:
      valIndex - The index of the array of bytes to be retrieved
      Returns:
      byte[]
    • getBytes32

      public byte[] getBytes32(int valIndex)
      Get the nth fixed-width 32-byte value in the result.

      This is the native word size for the Solidity ABI.

      Parameters:
      valIndex - The index of the array of bytes to be retrieved
      Returns:
      byte[]
    • getBool

      public boolean getBool(int valIndex)
      Get the nth value as a boolean.
      Parameters:
      valIndex - The index of the boolean to be retrieved
      Returns:
      boolean
    • getInt8

      public byte getInt8(int valIndex)
      Get the nth returned value as an 8-bit integer.

      If the actual value is wider it will be truncated to the last byte (similar to Java's integer narrowing semantics).

      If you are developing a contract and intending to return more than one of these values from a Solidity function, consider using the bytes32 Solidity type instead as that will be a more compact representation which will save on gas. (Each individual int8 value is padded to 32 bytes in the ABI.)

      Parameters:
      valIndex - The index of the value to be retrieved
      Returns:
      byte
    • getInt32

      public int getInt32(int valIndex)
      Get the nth returned value as a 32-bit integer.

      If the actual value is wider it will be truncated to the last 4 bytes (similar to Java's integer narrowing semantics).

      Parameters:
      valIndex - The index of the value to be retrieved
      Returns:
      int
    • getInt64

      public long getInt64(int valIndex)
      Get the nth returned value as a 64-bit integer.

      If the actual value is wider it will be truncated to the last 8 bytes (similar to Java's integer narrowing semantics).

      Parameters:
      valIndex - The index of the value to be retrieved
      Returns:
      long
    • getInt256

      public BigInteger getInt256(int valIndex)
      Get the nth returned value as a 256-bit integer.

      This type can represent the full width of Solidity integers.

      Parameters:
      valIndex - The index of the value to be retrieved
      Returns:
      BigInteger
    • getUint8

      public byte getUint8(int valIndex)
      Get the nth returned value as a 8-bit unsigned integer.

      If the actual value is wider it will be truncated to the last byte (similar to Java's integer narrowing semantics).

      Because Java does not have native unsigned integers, this is semantically identical to getInt8(int). To treat the value as unsigned in the range [0, 255], use Byte.toUnsignedInt(byte) to widen to int without sign-extension.

      If you are developing a contract and intending to return more than one of these values from a Solidity function, consider using the bytes32 Solidity type instead as that will be a more compact representation which will save on gas. (Each individual uint8 value is padded to 32 bytes in the ABI.)

      Parameters:
      valIndex - The index of the value to be retrieved
      Returns:
      byte
    • getUint32

      public int getUint32(int valIndex)
      Get the nth returned value as a 32-bit unsigned integer.

      If the actual value is wider it will be truncated to the last 4 bytes (similar to Java's integer narrowing semantics).

      Because Java does not have native unsigned integers, this is semantically identical to getInt32(int). The Integer class has static methods for treating an int as unsigned where the difference between signed and unsigned actually matters (comparison, division, printing and widening to long).

      Parameters:
      valIndex - The index of the value to be retrieved
      Returns:
      int
    • getUint64

      public long getUint64(int valIndex)
      Get the nth returned value as a 64-bit integer.

      If the actual value is wider it will be truncated to the last 8 bytes (similar to Java's integer narrowing semantics).

      Because Java does not have native unsigned integers, this is semantically identical to getInt64(int). The Long class has static methods for treating a long as unsigned where the difference between signed and unsigned actually matters (comparison, division and printing).

      Parameters:
      valIndex - The index of the value to be retrieved
      Returns:
      long
    • getUint256

      public BigInteger getUint256(int valIndex)
      Get the nth returned value as a 256-bit unsigned integer.

      The value will be padded with a leading zero-byte so that BigInteger(byte[]) treats the value as positive regardless of whether the most significant bit is set or not.

      This type can represent the full width of Solidity integers.

      Parameters:
      valIndex - The index of the value to be retrieved
      Returns:
      BigInteger
    • getAddress

      public String getAddress(int valIndex)
      Get the nth returned value as a Solidity address.
      Parameters:
      valIndex - The index of the value to be retrieved
      Returns:
      String
    • toProtobuf

      Create the protobuf representation.
      Returns:
      ContractFunctionResult
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getResult

      public com.esaulpaugh.headlong.abi.Tuple getResult(String types)