java.lang.Object
com.hedera.hashgraph.sdk.TokenId
- All Implemented Interfaces:
Comparable<TokenId>
Constructs a TokenId.
See Hedera Documentation
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbooleanstatic TokenIdfromBytes(byte[] bytes) Create a token id from a byte array.static TokenIdfromEvmAddress(long shard, long realm, String evmAddress) Constructs a TokenID from shard, realm, and EVM address.(package private) static TokenIdfromProtobuf(TokenID tokenId) Create a token id from a protobuf.static TokenIdfromSolidityAddress(String address) Deprecated.This method is deprecated.static TokenIdfromString(String id) Create a token id from a string.@Nullable StringExtract the checksum.inthashCode()nft(long serial) Create an nft id.byte[]toBytes()Create the byte array.Converts this TokenId to an EVM address string.(package private) TokenIDCreate the protobuf.Deprecated.This method is deprecated.toString()toStringWithChecksum(Client client) Create a string representation with checksum.voidDeprecated.UsevalidateChecksum(Client)instead.voidvalidateChecksum(Client client) Validate the configured client.
-
Field Details
-
shard
public final long shardThe shard number. Always non-negative. -
realm
public final long realmThe realm number. Always non-negative. -
num
public final long numThe id number. Always non-negative.
-
-
Constructor Details
-
TokenId
Deprecated.Constructor.- Parameters:
num- the num part, must be non-negative Constructor that uses shard, realm and num should be used instead as shard and realm should not assume 0 value
-
TokenId
public TokenId(long shard, long realm, long num) Constructor.- Parameters:
shard- the shard part, must be non-negativerealm- the realm part, must be non-negativenum- the num part, must be non-negative
-
TokenId
TokenId(long shard, long realm, long num, @Nullable String checksum) Constructor.- Parameters:
shard- the shard part, must be non-negativerealm- the realm part, must be non-negativenum- the num part, must be non-negativechecksum- the checksum
-
-
Method Details
-
fromString
Create a token id from a string.- Parameters:
id- the string representation- Returns:
- the new token id
-
fromProtobuf
Create a token id from a protobuf.- Parameters:
tokenId- the protobuf- Returns:
- the new token id
-
fromBytes
public static TokenId fromBytes(byte[] bytes) throws com.google.protobuf.InvalidProtocolBufferException Create a token id from a byte array.- Parameters:
bytes- the byte array- Returns:
- the new token id
- Throws:
com.google.protobuf.InvalidProtocolBufferException- when there is an issue with the protobuf
-
fromSolidityAddress
Deprecated.This method is deprecated. UsefromEvmAddress(long, long, String)instead.Retrieve the token id from a solidity address.- Parameters:
address- a string representing the address- Returns:
- the token id object
-
fromEvmAddress
Constructs a TokenID 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, must be non-negativerealm- the realm number, must be non-negativeevmAddress- the EVM address as a hex string- Returns:
- the TokenID object
- Throws:
IllegalArgumentException- if the EVM address is not a valid long zero address
-
toEvmAddress
Converts this TokenId 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
-
nft
Create an nft id.- Parameters:
serial- the serial number, must be non-negative- Returns:
- the new nft id
-
toSolidityAddress
Deprecated.This method is deprecated. UsetoEvmAddress()instead.Extract the solidity address.- Returns:
- the solidity address as a string
-
toProtobuf
TokenID toProtobuf()Create the protobuf.- Returns:
- a protobuf representation
-
validate
Deprecated.UsevalidateChecksum(Client)instead.- Parameters:
client- to validate against- Throws:
BadEntityIdException- if entity ID is formatted poorly
-
validateChecksum
Validate the configured client.- Parameters:
client- the configured client- Throws:
BadEntityIdException- if entity ID is formatted poorly
-
getChecksum
Extract the checksum.- Returns:
- the checksum
-
toBytes
public byte[] toBytes()Create the byte array.- Returns:
- the byte array representation
-
toString
-
toStringWithChecksum
Create a string representation with checksum.- Parameters:
client- the configured client- Returns:
- the string representation with checksum
-
hashCode
public int hashCode() -
equals
-
compareTo
- Specified by:
compareToin interfaceComparable<TokenId>
-