java.lang.Object
com.hedera.hashgraph.sdk.AccountId
- All Implemented Interfaces:
Comparable<AccountId>
The ID for a cryptocurrency account on Hedera.
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal PublicKeyThe public key bytes to be used as the account's aliasfinal EvmAddressThe ethereum account 20-byte EVM address to be used initially in place of the public key bytesfinal longThe id numberfinal longThe realm numberfinal longThe shard number -
Constructor Summary
ConstructorsConstructorDescriptionAccountId(long num) Deprecated.AccountId(long shard, long realm, long num) Assign all parts of the account id.Assign all parts of the account id.AccountId(long shard, long realm, long num, String checksum, PublicKey aliasKey, EvmAddress evmAddress) Assign all parts of the account id. -
Method Summary
Modifier and TypeMethodDescriptionintbooleanstatic AccountIdfromBytes(byte[] bytes) Retrieve the account id from a protobuf byte array.static AccountIdfromEvmAddress(EvmAddress evmAddress) Deprecated.static AccountIdfromEvmAddress(EvmAddress evmAddress, long shard, long realm) Retrieve the account id from an EVM address.static AccountIdfromEvmAddress(String evmAddress) Deprecated.static AccountIdfromEvmAddress(String evmAddress, long shard, long realm) Retrieve the account id from an EVM address.(package private) static AccountIdfromProtobuf(AccountID accountId) Retrieve the account id from a protobuf.static AccountIdfromSolidityAddress(String address) Deprecated.This method is deprecated.static AccountIdfromString(String id) Retrieve the account id from a string.Extract the checksum.inthashCode()populateAccountEvmAddress(Client client) Populates `evmAddress` field of the `AccountId` extracted from the Mirror Node.populateAccountEvmAddressAsync(Client client) Deprecated.Use 'populateAccountEvmAddress' instead due to its nearly identical operation.populateAccountNum(Client client) Gets the actual `num` field of the `AccountId` from the Mirror Node.populateAccountNumAsync(Client client) Deprecated.Use 'populateAccountNum' instead due to its nearly identical operation.byte[]toBytes()Extract a byte array representation.toEvmAddress returns EVM-compatible address representation of the entity(package private) AccountIDExtract the account id protobuf.Deprecated.This method is deprecated.toString()toStringWithChecksum(Client client) Extract a string representation with the checksum.voidDeprecated.UsevalidateChecksum(Client)instead.voidvalidateChecksum(Client client) Verify that the client has a valid checksum.
-
Field Details
-
shard
@Nonnegative public final long shardThe shard number -
realm
@Nonnegative public final long realmThe realm number -
num
@Nonnegative public final long numThe id number -
aliasKey
The public key bytes to be used as the account's alias -
evmAddress
The ethereum account 20-byte EVM address to be used initially in place of the public key bytes
-
-
Constructor Details
-
AccountId
Deprecated.Assign the num part of the account id.- Parameters:
num- the num part of the account id Constructor that uses shard, realm and num should be used instead as shard and realm should not assume 0 value
-
AccountId
public AccountId(@Nonnegative long shard, @Nonnegative long realm, @Nonnegative long num) Assign all parts of the account id.- Parameters:
shard- the shard part of the account idrealm- the realm part of the account idnum- the num part of the account id
-
AccountId
AccountId(@Nonnegative long shard, @Nonnegative long realm, @Nonnegative long num, @Nullable String checksum) Assign all parts of the account id.- Parameters:
shard- the shard part of the account idrealm- the realm part of the account idnum- the num part of the account id
-
AccountId
AccountId(@Nonnegative long shard, @Nonnegative long realm, @Nonnegative long num, @Nullable String checksum, @Nullable PublicKey aliasKey, @Nullable EvmAddress evmAddress) Assign all parts of the account id.- Parameters:
shard- the shard part of the account idrealm- the realm part of the account idnum- the num part of the account id
-
-
Method Details
-
fromString
Retrieve the account id from a string.- Parameters:
id- a string representing a valid account id- Returns:
- the account id object
- Throws:
IllegalArgumentException- when the account id and checksum are invalid
-
fromEvmAddress
Deprecated.Retrieve the account id from an EVM address.- Parameters:
evmAddress- a string representing the EVM address- Returns:
- the account id object Constructor that uses shard, realm and num should be used instead as shard and realm should not assume 0 value
-
fromEvmAddress
public static AccountId fromEvmAddress(String evmAddress, @Nonnegative long shard, @Nonnegative long realm) Retrieve the account id from an EVM address.- Parameters:
evmAddress- a string representing the EVM addressshard- the shard part of the account idrealm- the shard realm of the account id- Returns:
- the account id object In case shard and realm are unknown, they should be set to zero
-
fromEvmAddress
Deprecated.Retrieve the account id from an EVM address.- Parameters:
evmAddress- an EvmAddress instance- Returns:
- the account id object Constructor that uses shard, realm and num should be used instead as shard and realm should not assume 0 value
-
fromEvmAddress
public static AccountId fromEvmAddress(EvmAddress evmAddress, @Nonnegative long shard, @Nonnegative long realm) Retrieve the account id from an EVM address.- Parameters:
evmAddress- an EvmAddress instanceshard- the shard part of the account idrealm- the shard realm of the account id- Returns:
- the account id object In case shard and realm are unknown, they should be set to zero
-
fromSolidityAddress
Deprecated.This method is deprecated. UsefromEvmAddress(EvmAddress, long, long)instead.Retrieve the account id from a solidity address.- Parameters:
address- a string representing the address- Returns:
- the account id object
-
fromProtobuf
Retrieve the account id from a protobuf.- Parameters:
accountId- the protobuf- Returns:
- the account id object
-
fromBytes
public static AccountId fromBytes(byte[] bytes) throws com.google.protobuf.InvalidProtocolBufferException Retrieve the account id from a protobuf byte array.- Parameters:
bytes- a byte array representation of the protobuf- Returns:
- the account id object
- Throws:
com.google.protobuf.InvalidProtocolBufferException- when there is an issue with the protobuf
-
toSolidityAddress
Deprecated.This method is deprecated. UsetoEvmAddress()instead.Extract the solidity address.- Returns:
- the solidity address as a string
-
toEvmAddress
toEvmAddress returns EVM-compatible address representation of the entity- Returns:
-
toProtobuf
AccountID toProtobuf()Extract the account id protobuf.- Returns:
- the account id builder
-
populateAccountNum
Gets the actual `num` field of the `AccountId` from the Mirror Node. Should be used after generating `AccountId.fromEvmAddress()` because it sets the `num` field to `0` automatically since there is no connection between the `num` and the `evmAddress` Sync version- Parameters:
client-- Returns:
- populated AccountId instance
- Throws:
InterruptedExceptionExecutionException
-
populateAccountNumAsync
Deprecated.Use 'populateAccountNum' instead due to its nearly identical operation.Gets the actual `num` field of the `AccountId` from the Mirror Node. Should be used after generating `AccountId.fromEvmAddress()` because it sets the `num` field to `0` automatically since there is no connection between the `num` and the `evmAddress` Async version- Parameters:
client-- Returns:
- populated AccountId instance
-
populateAccountEvmAddress
public AccountId populateAccountEvmAddress(Client client) throws ExecutionException, InterruptedException Populates `evmAddress` field of the `AccountId` extracted from the Mirror Node. Sync version- Parameters:
client-- Returns:
- populated AccountId instance
- Throws:
ExecutionExceptionInterruptedException
-
populateAccountEvmAddressAsync
Deprecated.Use 'populateAccountEvmAddress' instead due to its nearly identical operation.Populates `evmAddress` field of the `AccountId` extracted from the Mirror Node. Async version- Parameters:
client-- Returns:
- populated AccountId instance
-
validate
Deprecated.UsevalidateChecksum(Client)instead.- Parameters:
client- to validate against- Throws:
BadEntityIdException- if entity ID is formatted poorly
-
validateChecksum
Verify that the client has a valid checksum.- Parameters:
client- the client to verify- Throws:
BadEntityIdException- when the account id and checksum are invalid
-
getChecksum
Extract the checksum.- Returns:
- the checksum
-
toBytes
public byte[] toBytes()Extract a byte array representation.- Returns:
- a byte array representation
-
toString
-
toStringWithChecksum
Extract a string representation with the checksum.- Parameters:
client- the client- Returns:
- the account id with checksum
-
hashCode
public int hashCode() -
equals
-
compareTo
- Specified by:
compareToin interfaceComparable<AccountId>
-