Contract Param¶
ContractParam provides a type-safe way to define parameters passed to Hiero smart contract creation and function execution APIs.
It represents Solidity compatible values that can be converted into contract function parameters.
Each parameter contains:
- The Java value
- The Solidity native type
ContractParam is used with SmartContractClient methods such as:
createContract()callContractFunction()
Supported Parameter Types¶
| Method | Solidity Type | Description |
|---|---|---|
string(String value) |
string |
Creates a string parameter. |
bytes(byte[] value) |
bytes |
Creates a bytes parameter. |
bytes32(byte[] value) |
bytes32 |
Creates a fixed 32-byte parameter. |
address(String value) |
address |
Creates an address parameter from an account ID. |
address(AccountId value) |
address |
Creates an address parameter from an AccountId. |
address(ContractId value) |
address |
Creates an address parameter from a ContractId. |
bool(boolean value) |
bool |
Creates a boolean parameter. |
int8() - int64() |
intN |
Creates signed integer parameters. |
uint8() - uint64() |
uintN |
Creates unsigned integer parameters. |
int72() - int256() |
intN |
Creates large signed integer parameters using BigInteger. |
uint72() - uint256() |
uintN |
Creates large unsigned integer parameters using BigInteger. |
String Parameters¶
Creates a Solidity string parameter.
ContractParam<String> param =
ContractParam.string("Hello Hiero");
Bytes Parameters¶
Creates Solidity byte parameters.
ContractParam<Bytes> param =
ContractParam.bytes("Hello".getBytes());
Creates a fixed size bytes32 parameter.
ContractParam<Bytes> param =
ContractParam.bytes32("Hello".getBytes());
Note
bytes32 values must not exceed 32 bytes.
Address Parameters¶
Creates a Solidity address parameter.
Creates a Solidity address parameter from an AccountId.
AccountId accountId = AccountId.fromString("0.0.1234");
ContractParam<String> param =
ContractParam.address(accountId);
Creates a Solidity address parameter from a ContractId.
ContractId contractId = ContractId.fromString("0.0.5678");
ContractParam<String> param =
ContractParam.address(contractId);
Creates a Solidity address parameter using an already converted Solidity address.
ContractParam<String> param =
ContractParam.addressBySolidty("00000000000000000000000000000000000004d2");
Note
addressBySolidty() expects a Solidity address string. Unlike address(String), the value is not converted from a Hiero account ID such as 0.0.1234.
Boolean Parameters¶
Creates a Solidity bool parameter.
Integer Parameters¶
Creates Solidity integer parameters.
Small Integer Types¶
Large Integer Types¶
Large integer values use BigInteger.
ContractParam<BigInteger> param =
ContractParam.int256(BigInteger.valueOf(100));
ContractParam<BigInteger> param =
ContractParam.uint256(BigInteger.valueOf(100));
Using Contract Parameters¶
Parameters can be supplied when deploying contracts or executing contract functions.