Class FileId

java.lang.Object
com.hedera.hashgraph.sdk.FileId
All Implemented Interfaces:
Comparable<FileId>

public final class FileId extends Object implements Comparable<FileId>
The ID for a file on Hedera.
  • Field Details

    • ADDRESS_BOOK

      public static final FileId ADDRESS_BOOK
      The public node address book for the current network.
    • FEE_SCHEDULE

      public static final FileId FEE_SCHEDULE
      The current fee schedule for the network.
    • EXCHANGE_RATES

      public static final FileId EXCHANGE_RATES
      The current exchange rate of HBAR to USD.
    • shard

      @Nonnegative public final long shard
      The shard number
    • realm

      @Nonnegative public final long realm
      The realm number
    • num

      @Nonnegative public final long num
      The id number
  • Constructor Details

    • FileId

      @Deprecated public FileId(@Nonnegative long num)
      Deprecated.
      Assign the num portion of the file id.
      Parameters:
      num - the num portion not negative Constructor that uses shard, realm and num should be used instead as shard and realm should not assume 0 value
    • FileId

      public FileId(@Nonnegative long shard, @Nonnegative long realm, @Nonnegative long num)
      Assign the file id.
      Parameters:
      shard - the shard portion
      realm - the realm portion
      num - the num portion
    • FileId

      FileId(@Nonnegative long shard, @Nonnegative long realm, @Nonnegative long num, @Nullable String checksum)
      Assign the file id and optional checksum.
      Parameters:
      shard - the shard portion
      realm - the realm portion
      num - the num portion
      checksum - the optional checksum
  • Method Details

    • getAddressBookFileIdFor

      public static FileId getAddressBookFileIdFor(long shard, long realm)
      Get the `FileId` of the Hedera address book for the given realm and shard.
      Parameters:
      shard -
      realm -
      Returns:
      FileId
    • getFeeScheduleFileIdFor

      public static FileId getFeeScheduleFileIdFor(long shard, long realm)
      Get the `FileId` of the Hedera fee schedule for the given realm and shard.
      Parameters:
      shard -
      realm -
      Returns:
      FileId
    • getExchangeRatesFileIdFor

      public static FileId getExchangeRatesFileIdFor(long shard, long realm)
      Get the `FileId` of the Hedera exchange rates for the given realm and shard.
      Parameters:
      shard -
      realm -
      Returns:
      FileId
    • fromString

      public static FileId fromString(String id)
      Assign the file id from a string.
      Parameters:
      id - the string representation of a file id
      Returns:
      the file id object
    • fromBytes

      public static FileId fromBytes(byte[] bytes) throws com.google.protobuf.InvalidProtocolBufferException
      Assign the file id from a byte array.
      Parameters:
      bytes - the byte array representation of a file id
      Returns:
      the file id object
      Throws:
      com.google.protobuf.InvalidProtocolBufferException - when there is an issue with the protobuf
    • fromProtobuf

      static FileId fromProtobuf(FileID fileId)
      Create a file id object from a protobuf.
      Parameters:
      fileId - the protobuf
      Returns:
      the file id object
    • fromSolidityAddress

      @Deprecated public static FileId fromSolidityAddress(String address)
      Deprecated.
      This method is deprecated. Use fromEvmAddress(long, long, String) instead.
      Retrieve the file id from a solidity address.
      Parameters:
      address - a string representing the address
      Returns:
      the file id object
    • toSolidityAddress

      @Deprecated public String toSolidityAddress()
      Deprecated.
      This method is deprecated. Use toEvmAddress() instead.
      Extract the solidity address.
      Returns:
      the solidity address as a string
    • fromEvmAddress

      public static FileId fromEvmAddress(long shard, long realm, String evmAddress)
      Constructs a FileId from shard, realm, and EVM address. The EVM address must be a "long zero address" (first 12 bytes are zero).
      Parameters:
      shard - the shard number
      realm - the realm number
      evmAddress - the EVM address as a hex string
      Returns:
      the FileId object
      Throws:
      IllegalArgumentException - if the EVM address is not a valid long zero address
    • toEvmAddress

      public String toEvmAddress()
      Converts this FileId to an EVM address string. Creates a solidity address using shard=0, realm=0, and the file number.
      Returns:
      the EVM address as a hex string
    • toProtobuf

      FileID toProtobuf()
      Returns:
      protobuf representing the file id
    • validate

      @Deprecated public void validate(Client client) throws BadEntityIdException
      Deprecated.
      Parameters:
      client - to validate against
      Throws:
      BadEntityIdException - if entity ID is formatted poorly
    • validateChecksum

      public void validateChecksum(Client client) throws BadEntityIdException
      Validate that the client is configured correctly.
      Parameters:
      client - the client to validate
      Throws:
      BadEntityIdException - if entity ID is formatted poorly
    • getChecksum

      @Nullable public String getChecksum()
      Extract the checksum.
      Returns:
      the checksum
    • toBytes

      public byte[] toBytes()
      Create the byte array.
      Returns:
      byte array representation
    • toString

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

      public String toStringWithChecksum(Client client)
      Convert the client to a string representation with a checksum.
      Parameters:
      client - the client to stringify
      Returns:
      string representation with checksum
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(FileId o)
      Specified by:
      compareTo in interface Comparable<FileId>