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[]The 20-byte EVM address of the contract to call.final longThe id numberfinal longThe realm numberfinal longThe shard numberFields 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, 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.Extract 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
@Nonnegative public final long shardThe shard number -
realm
@Nonnegative public final long realmThe realm number -
num
@Nonnegative public final long numThe id number -
evmAddress
@Nullable public final byte[] 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 Constructor that uses shard, realm and num should be used instead as shard and realm should not assume 0 value
-
ContractId
public ContractId(@Nonnegative long shard, @Nonnegative long realm, @Nonnegative long num) Assign all parts of the contract id.- Parameters:
shard- the shard part of the contract idrealm- the realm part of the contract idnum- the num part of the contract id
-
ContractId
ContractId(@Nonnegative long shard, @Nonnegative long realm, @Nonnegative long num, @Nullable String checksum) Assign all parts of the contract id.- Parameters:
shard- the shard part of the contract idrealm- the realm part of the contract idnum- the num part of the contract id
-
ContractId
ContractId(@Nonnegative long shard, @Nonnegative 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
public static ContractId fromEvmAddress(@Nonnegative long shard, @Nonnegative long realm, String evmAddress) Parse contract id from an ethereum address.- Parameters:
shard- the desired shardrealm- the desired realmevmAddress- 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:
-
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>
-