Hedera
Search…
Specialized Types

AccountId

An AccountId is composed of a <shardNum>.<realmNum>.<accountNum> (eg. 0.0.10).
    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.
    accountNum represents the account number (accountId)
Together these values make up your AccountId. When an AccountId is requested, be sure all three values are included.

Constructor

Constructor
Type
Description
new AccountId(<shardNum>,<realmNum>,<accountNum>)
long, long, long
Constructs an AccountId with 0 for shardNum and realmNum (e.g., 0.0.<accountNum>)

Methods

Methods
Type
Description
fromString(<account>)
String
Constructs an AccountId from a string formatted as <shardNum>.<realmNum>.<accountNum>
fromSolidityAddress(<address>)
String
Constructs an AccountId from a solidity address in string format

Example

Java
JavaScript
1
AccountId accountId = new AccountId(0 ,0 ,10);
2
System.out.println(accountId);
3
4
// Constructs an accountId from String
5
AccountId accountId = AccountId.fromString("0.0.10");
6
System.out.println(accountId);
Copied!
1
const acctId = new AccountId(100);
2
console.log(`${acctId}`);
3
4
// Construct accountId from String
5
const acctId = AccountId.fromString(`100`);
6
console.log(`${acctId}`);
Copied!

FileId

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

Constructor
Type
Description
new FileId(<shardNum>,<realmNum>,<fileNum>)
long, long, long
Constructs a FileId with 0 for shardNum and realmNum (e.g., 0.0.<fileNum>)

Methods

Methods
Type
Description
fromString()
String
Constructs an FileId from a string formatted as
<shardNum>.<realmNum>.<fileNum>
fromSolidityAddress()
String
Constructs an FileId from a solidity address in string format
FileId.ADDRESS_BOOK
FileId
The public node address book for the current network
FileId.EXCHANGE_RATES
FileId
The current exchange rate of HBAR to USD
FileId.FEE_SCHEDULE
FileId
The current fee schedule for the network

Example

Java
JavaScript
1
FileId fileId = new FileId(0,0,15);
2
System.out.println(fileId);
3
4
//Constructs a FileId from string
5
FileId fileId = FileId.fromString("0.0.15");
6
System.out.println(fileId);
Copied!
1
const newFileId = new FileId(100);
2
console.log(`${newFileId}`);
3
4
//Construct a fileId from a String
5
const newFileIdFromString = FileId.fromString(`100`);
6
console.log(`${newFileIdFromString}`);
Copied!
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

Methods
Type
Description
fromString(<account>)
String
Constructs a ContractId from a string formatted as
<shardNum>.<realmNum>.<contractNum>
fromSolidityAddress(<address>)
String
Constructs a ContractId from a solidity address in string format

Example

Java
JavaScript
1
ContractId contractId = new ContractId(0,0,20);
2
System.out.println(contractId);
3
4
// Constructs a ContractId from string
5
ContractId contractId = ContractId.fromString("0.0.20");
6
System.out.println(contractId);
Copied!
1
const newContractId = new ContractId(100);
2
console.log(`${newContractId}`);
3
4
// Construct a contractId from a String
5
const newContractId = ContractId.fromString(`100`);
6
console.log(`${newContractId}`);
Copied!
A TransactionId is composed of the current time and account that is primarily signing the transaction. Every transaction has an associated TransactionId. Transaction IDs are automatically assigned for every transaction that is submitted to the network.

Constructor

Constructor
Type
Description
new TransactionId(<accountId>)
AccountId
Generates a new transaction ID for the given accountId.

Example

Java
JavaScript
1
TransactionId transactionId = new TransactionId(myAccountId);
Copied!
1
const txId = new TransactionId(newAccountId);
2
console.log(`${txId}`);
Copied!

TopicId

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

Constructor
Type
Description
new ConsensusTopicId(<shardNum>,<realmNum>,<topicNum>)
long, long, long
Constructs a TopicId with 0 for shardNum and realmNum (e.g., 0.0.<topicNum>)
Methods
Type
Description
fromString(<topic>)
String
Constructs a topic ID from a String
ConsensusTopicId.toString()
Constructs a topic ID to String format

Example

Java
JavaScript
1
ConsensusTopicId topicId = new ConsensusTopicId(0,0,100);
2
System.out.println(topicId)
Copied!
1
const topicId = new ConsensusTopicId(0,0,100);
2
System.out.println(topicId)
Copied!
Last modified 6d ago