> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hedera.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Specialized Types

## [AccountId](https://github.com/hashgraph/hedera-sdk-java/blob/master/src/main/java/com/hedera/hashgraph/sdk/account/AccountId.java)

An `AccountId` is composed of a \<shardNum>.\<realmNum>.\<accountNum> (eg. 0.0.10).

* Shard number (`shardNum`**)** represents the shard number (`shardId`). It will default to 0 today, as Hedera only performs in one shard.
* Realm number (`realmNum`) represents the realm number (`realmId`). It will default to 0 today, as realms are not yet supported.
* Account represents either an account number or an account alias
  * Account number (`accountNum`) represents the account number (`accountId`)
  * Account alias (alias) represented by the public key bytes
    * The public key bytes are the result of serializing a protobuf Key message for any primitive key type
    * Currently, only primitive key bytes are supported as an alias
    * Threshold keys, key list, contract ID, and delegatable\_contract\_id are not supported
    * The alias can only be used in place of an account ID in transfer transactions in its current version

Together these values make up your `AccountId`. When an `AccountId` is specified, be sure all three values are included.

### Constructor

<table><thead><tr><th /><th align="center" /><th /></tr></thead><tbody><tr><td><strong>Constructor</strong></td><td align="center"><strong>Type</strong></td><td><strong>Description</strong></td></tr><tr><td><code>new AccountId(\<shardNum>,\<realmNum>,\<accountNum>)</code></td><td align="center">long, long, long</td><td>Constructs an <code>AccountId</code> with 0 for <code>shardNum</code> and <code>realmNum</code> (e.g., <code>0.0.\<accountNum></code>)</td></tr></tbody></table>

### Methods

<table><thead><tr><th /><th /><th /></tr></thead><tbody><tr><td><strong>Methods</strong></td><td><strong>Type</strong></td><td><strong>Description</strong></td></tr><tr><td><code>AccountId.fromString(\<account>)</code></td><td>String</td><td>Constructs an <code>AccountId</code> from a string formatted as \<shardNum>.\<realmNum>.\<accountNum></td></tr><tr><td><code>AccountId.fromEvmAddress(\<address>)</code></td><td>String</td><td>Constructs an <code>AccountId</code> from a solidity address in string format</td></tr><tr><td><code>AccountId.fromBytes(bytes)</code></td><td>byte\[]</td><td>Constructs an <code>AccountId</code> from bytes</td></tr><tr><td><code>AccountId.toSolidityAddress()</code></td><td>String</td><td>Constructs a solidity address from <code>AccountID</code></td></tr><tr><td><code>AccountId.toString()</code></td><td>String</td><td>Constructs an <code>AccountID</code> from string</td></tr><tr><td><code>AccountId.aliasKey</code></td><td>PublicKey</td><td>The alias key of the <code>AccountID</code></td></tr><tr><td><code>AccountId.aliasEvmAddress</code></td><td>EVM address</td><td>The EVM address of the <code>AccountID</code></td></tr><tr><td><code>AccountId.toBytes()</code></td><td>byte\[]</td><td>Constructs an <code>AccountID</code> from bytes</td></tr></tbody></table>

### Example

<CodeGroup>
  ```java Java theme={null}
  AccountId accountId = new AccountId(0 ,0 ,10);
  System.out.println(accountId);

  // Constructs an accountId from String
  AccountId accountId = AccountId.fromString("0.0.10");
  System.out.println(accountId);
  ```

  ```javascript JavaScript theme={null}
  const accountId = new AccountId(100);
  console.log(`${accountId}`);

  // Construct accountId from String
  const accountId = AccountId.fromString(`100`);
  console.log(`${accountId}`);
  ```

  ```go Go theme={null}
  hedera.AccountIDFromString("0.0.3")
  ```
</CodeGroup>

## [FileId](https://github.com/hashgraph/hedera-sdk-java/blob/master/src/main/java/com/hedera/hashgraph/sdk/file/FileId.java)

A `FileId` is composed of a \<shardNum>.\<realmNum>.\<fileNum> (eg. 0.0.15).

* **shardNum** represents the shard number (`shardId`). It will default to 0 today, as Hedera only performs in one shard.
* **realmNum** represents the realm number (`realmId`). It will default to 0 today, as realms are not yet supported.
* **fileNum** represents the file number

Together these values make up your accountId. When an `FileId` is requested, be sure all three values are included.

### Constructor

<table><thead><tr><th /><th align="center" /><th /></tr></thead><tbody><tr><td><strong>Constructor</strong></td><td align="center"><strong>Type</strong></td><td><strong>Description</strong></td></tr><tr><td><code>new FileId(\<shardNum>,\<realmNum>,\<fileNum>)</code></td><td align="center">long, long, long</td><td>Constructs a <code>FileId</code> with 0 for <code>shardNum</code> and <code>realmNum</code> (e.g., <code>0.0.\<fileNum></code>)</td></tr></tbody></table>

### Methods

<table><thead><tr><th /><th /><th /></tr></thead><tbody><tr><td><strong>Methods</strong></td><td><strong>Type</strong></td><td><strong>Description</strong></td></tr><tr><td><code>FileId.fromString()</code></td><td>String</td><td><p>Constructs an <code>FileId</code> from a string formatted as</p><p>\<shardNum>.\<realmNum>.\<fileNum></p></td></tr><tr><td><code>FileId.fromSolidityAddress()</code></td><td>String</td><td>Constructs an <code>FileId</code> from a solidity address in string format</td></tr><tr><td><code>FileId.ADDRESS\_BOOK</code></td><td>FileId</td><td>The public node address book for the current network</td></tr><tr><td><code>FileId.EXCHANGE\_RATES</code></td><td>FileId</td><td>The current exchange rate of HBAR to USD</td></tr><tr><td><code>FileId.FEE\_SCHEDULE</code></td><td>FileId</td><td>The current fee schedule for the network</td></tr></tbody></table>

### Example

<CodeGroup>
  ```java Java theme={null}
  FileId fileId = new FileId(0,0,15);
  System.out.println(fileId);

  //Constructs a FileId from string
  FileId fileId = FileId.fromString("0.0.15");
  System.out.println(fileId);
  ```

  ```javascript JavaScript theme={null}
  const newFileId = new FileId(100);
  console.log(`${newFileId}`);

  //Construct a fileId from a String
  const newFileIdFromString = FileId.fromString(`100`); 
  console.log(`${newFileIdFromString}`);
  ```

  ```go Go theme={null}
  hedera.FileIDFromString("0.0.3")
  ```
</CodeGroup>

## [ContractId](https://github.com/hashgraph/hedera-sdk-java/blob/master/src/main/java/com/hedera/hashgraph/sdk/contract/ContractId.java)

A `ContractId` is composed of a \<shardNum>.\<realmNum>.\<contractNum> (eg. 0.0.20).

* **shardNum** represents the shard number (`shardId`). It will default to 0 today, as Hedera only performs in one shard.
* **realmNum** represents the realm number (`realmId`). It will default to 0 today, as realms are not yet supported.
* **contractNum** represents the contract number

Together these values make up your `ContractId`. When an `ContractId` is requested, be sure all three values are included. ContractId's are automatically assigned when you create a new smart contract.

### Constructor

| **Constructor**                                       | **Type**         | **Description**                                                                            |
| ----------------------------------------------------- | ---------------- | ------------------------------------------------------------------------------------------ |
| `new ContractId(<shardNum>,<realmNum>,<contractNum>)` | long, long, long | Constructs a `ContractId` with 0 for `shardNum` and `realmNum` (e.g., `0.0.<contractNum>`) |

### Methods

<table><thead><tr><th /><th /><th /></tr></thead><tbody><tr><td><strong>Methods</strong></td><td><strong>Type</strong></td><td><strong>Description</strong></td></tr><tr><td><code>ContractId.fromString(\<account>)</code></td><td>String</td><td><p>Constructs a <code>ContractId</code> from a string formatted as</p><p>\<shardNum>.\<realmNum>.\<contractNum></p></td></tr><tr><td><code>ContractId.fromSolidityAddress(\<address>)\[deprecated use ConractId.fromEvmAddress()]</code></td><td>String</td><td>Constructs a <code>ContractId</code> from a solidity address in string format \[deprecated use <code>ContractId.fromEvmAddres()]</code></td></tr><tr><td><code>ContractId.toSolidityAddress(\<contractId>)</code></td><td>String</td><td>Contruct a Solidity address from a Hedera contract ID</td></tr><tr><td><code>ContractId.fromEvmAddress(\<shard>, \<realm>, \<evmAddress>)</code></td><td>long, long, String</td><td>Constructs a <code>ContractId</code> from evm address</td></tr></tbody></table>

### Example

<CodeGroup>
  ```java Java theme={null}
  ContractId contractId = new ContractId(0,0,20);
  System.out.println(contractId);

  // Constructs a ContractId from string
  ContractId contractId = ContractId.fromString("0.0.20");
  System.out.println(contractId);
  ```

  ```javascript JavaScript theme={null}
  const newContractId = new ContractId(100);
  console.log(`${newContractId}`);

  // Construct a contractId from a String
  const newContractId = ContractId.fromString(`100`); 
  console.log(`${newContractId}`);
  ```
</CodeGroup>

## [TopicId](https://github.com/hashgraph/hedera-sdk-java/blob/master/src/main/java/com/hedera/hashgraph/sdk/consensus/ConsensusTopicId.java)

A `topicId` is composed of a \<shardNum>.\<realmNum>.\<topicNum> (eg. 0.0.100).

* **shardNum** represents the shard number (`shardId`). It will default to 0 today, as Hedera only performs in one shard.
* **realmNum** represents the realm number (`realmId`). It will default to 0 today, as realms are not yet supported.
* **topicNum** represents the topic number (`topicId`)

### Constructor

<table><thead><tr><th /><th /><th /></tr></thead><tbody><tr><td><strong>Constructor</strong></td><td><strong>Type</strong></td><td><strong>Description</strong></td></tr><tr><td><code>new ConsensusTopicId(\<shardNum>,\<realmNum>,\<topicNum>)</code></td><td>long, long, long</td><td>Constructs a <code>TopicId</code> with <code>0</code> for <code>shardNum</code> and <code>realmNum</code> (e.g., <code>0.0.\<topicNum></code>)</td></tr></tbody></table>

<table><thead><tr><th /><th /><th /></tr></thead><tbody><tr><td><strong>Methods</strong></td><td><strong>Type</strong></td><td><strong>Description</strong></td></tr><tr><td><code>fromString(\<topic>)</code></td><td>String</td><td>Constructs a topic ID from a String</td></tr><tr><td><code>ConsensusTopicId.toString()</code></td><td /><td>Constructs a topic ID to String format</td></tr></tbody></table>

### Example

<CodeGroup>
  ```java Java theme={null}
  ConsensusTopicId topicId = new ConsensusTopicId(0,0,100);
  System.out.println(topicId)
  ```

  ```javascript JavaScript theme={null}
  const topicId = new ConsensusTopicId(0,0,100);
  console.log(topicId)
  ```

  ```go Go theme={null}
  hedera.TopicIDFromString("0.0.3")
  ```
</CodeGroup>
