java.lang.Object
com.hedera.hashgraph.sdk.Key
com.hedera.hashgraph.sdk.ContractId
- All Implemented Interfaces:
Comparable<ContractId>
- Direct Known Subclasses:
DelegateContractId
The ID for a smart contract instance on Hedera.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final Patternfinal byte @Nullable []The 20-byte EVM address of the contract to call.final longThe id number.final longThe realm number.final longThe shard number.Fields inherited from class com.hedera.hashgraph.sdk.Key
ECDSA_SECP256K1_CURVE, ECDSA_SECP256K1_DOMAIN, ID_EC_PUBLIC_KEY, ID_ECDSA_SECP256K1, ID_ED25519 -
Constructor Summary
ConstructorsConstructorDescriptionContractId(long num) Deprecated.ContractId(long shard, long realm, byte[] evmAddress) ContractId(long shard, long realm, long num) Assign all parts of the contract id.ContractId(long shard, long realm, long num, @Nullable String checksum) Assign all parts of the contract id. -
Method Summary
Modifier and TypeMethodDescriptionintbooleanstatic ContractIdfromBytes(byte[] bytes) Convert a byte array to an account balance object.static ContractIdfromEvmAddress(long shard, long realm, String evmAddress) Parse contract id from an ethereum address.(package private) static ContractIdfromProtobuf(ContractID contractId) Extract a contract id from a protobuf.static ContractIdfromSolidityAddress(String address) Deprecated.This method is deprecated.static ContractIdfromString(String id) Parse contract id from a string.@Nullable StringExtract the checksum.inthashCode()populateContractNum(Client client) Gets the actual `num` field of the `ContractId` from the Mirror Node.populateContractNumAsync(Client client) Deprecated.Use 'populateContractNum' instead due to its nearly identical operation.byte[]toBytes()Create the byte array.toEvmAddress returns EVM-compatible address representation of the entity(package private) ContractIDConvert contract id to protobuf.(package private) KeySerialize this key as a protobuf objectDeprecated.This method is deprecated.toString()toStringWithChecksum(Client client) Create a string representation that includes the checksum.voidDeprecated.UsevalidateChecksum(Client)instead.voidvalidateChecksum(Client client) Verify the checksum.Methods inherited from class com.hedera.hashgraph.sdk.Key
fromProtobufKey
-
Field Details
-
EVM_ADDRESS_REGEX
-
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. -
evmAddress
public final byte @Nullable [] evmAddressThe 20-byte EVM address of the contract to call.
-
-
Constructor Details
-
ContractId
Deprecated.Assign the num part of the contract id.- Parameters:
num- the num part of the account id, must be non-negative Constructor that uses shard, realm and num should be used instead as shard and realm should not assume 0 value
-
ContractId
public ContractId(long shard, long realm, long num) Assign all parts of the contract id.- Parameters:
shard- the shard part of the contract id, must be non-negativerealm- the realm part of the contract id, must be non-negativenum- the num part of the contract id, must be non-negative
-
ContractId
ContractId(long shard, long realm, long num, @Nullable String checksum) Assign all parts of the contract id.- Parameters:
shard- the shard part of the contract id, must be non-negativerealm- the realm part of the contract id, must be non-negativenum- the num part of the contract id, must be non-negative
-
ContractId
ContractId(long shard, long realm, byte[] evmAddress)
-
-
Method Details
-
fromString
Parse contract id from a string.- Parameters:
id- the string containing a contract id- Returns:
- the contract id object
-
fromSolidityAddress
Deprecated.This method is deprecated. UsefromEvmAddress(long, long, String)instead.Retrieve the contract id from a solidity address.- Parameters:
address- a string representing the address- Returns:
- the contract id object
-
fromEvmAddress
Parse contract id from an ethereum address.- Parameters:
shard- the desired shard, must be non-negativerealm- the desired realm, must be non-negativeevmAddress- the evm address- Returns:
- the contract id object
-
fromProtobuf
Extract a contract id from a protobuf.- Parameters:
contractId- the protobuf containing a contract id- Returns:
- the contract id object
-
fromBytes
public static ContractId fromBytes(byte[] bytes) throws com.google.protobuf.InvalidProtocolBufferException Convert a byte array to an account balance object.- Parameters:
bytes- the byte array- Returns:
- the converted contract 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:
- the EVM-compatible address representation of the contract
-
toProtobuf
ContractID toProtobuf()Convert contract id to protobuf.- Returns:
- the protobuf object
-
populateContractNum
public ContractId populateContractNum(Client client) throws InterruptedException, ExecutionException Gets the actual `num` field of the `ContractId` from the Mirror Node. Should be used after generating `ContractId.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 ContractId instance
- Throws:
InterruptedExceptionExecutionException
-
populateContractNumAsync
Deprecated.Use 'populateContractNum' instead due to its nearly identical operation.Gets the actual `num` field of the `ContractId` from the Mirror Node. Should be used after generating `ContractId.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 ContractId instance
-
validate
Deprecated.UsevalidateChecksum(Client)instead.- Parameters:
client- to validate against- Throws:
BadEntityIdException- if entity ID is formatted poorly
-
validateChecksum
Verify the checksum.- Parameters:
client- to validate against- Throws:
BadEntityIdException- if entity ID is formatted poorly
-
getChecksum
Extract the checksum.- Returns:
- the checksum
-
toProtobufKey
Key toProtobufKey()Description copied from class:KeySerialize this key as a protobuf object- Specified by:
toProtobufKeyin classKey
-
toBytes
public byte[] toBytes()Description copied from class:KeyCreate the byte array. -
toString
-
toStringWithChecksum
Create a string representation that includes the checksum.- Parameters:
client- the client- Returns:
- the string representation with the checksum
-
hashCode
public int hashCode() -
equals
-
compareTo
- Specified by:
compareToin interfaceComparable<ContractId>
-