Class QueryContractParams
Provides the details of the request to the client when invoking a contract local query function.
Inherited Members
Namespace: Hiero
Assembly: Hiero.dll
Syntax
public sealed class QueryContractParams
Examples
Query a read-only method on an existing contract. No transaction, no state change, no consensus timestamp — executed locally on the gateway:
var result = await client.QueryContractAsync(new QueryContractParams
{
Contract = contract,
Gas = 50_000,
MethodName = methodName
});
Console.WriteLine($"Result: {result}");
Properties
| Edit this page View SourceCancellationToken
Optional Cancellation token that can interrupt the query.
Declaration
public CancellationToken? CancellationToken { get; set; }
Property Value
| Type | Description |
|---|---|
| CancellationToken? |
Contract
The address of the contract to call.
Declaration
public EntityId Contract { get; set; }
Property Value
| Type | Description |
|---|---|
| EntityId |
Gas
The amount of gas that is allowed for the call.
Declaration
public long Gas { get; set; }
Property Value
| Type | Description |
|---|---|
| long |
MessageSender
The account that is the "message.sender" of the contract call, if not specified it is the transaction Payer.
Declaration
public EntityId MessageSender { get; set; }
Property Value
| Type | Description |
|---|---|
| EntityId |
MethodArgs
The function arguments to send with the method call.
Declaration
public object[] MethodArgs { get; set; }
Property Value
| Type | Description |
|---|---|
| object[] |
MethodName
Name of the contract function to call.
Declaration
public string MethodName { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
ReturnedDataGasAllowance
The amount of GAS required to pay for returning the output data from the contract. This is an additional fee that is incorporated into the max gas fee under the hood. Gas can be set at what a mirror node would estimate as the necessary charge, and this accounts for the bytes returned. Honestly, you should be using mirror nodes for read-only queries of the EVM anyway, it will be cheaper for your wallet.
Declaration
public long ReturnedDataGasAllowance { get; set; }
Property Value
| Type | Description |
|---|---|
| long |
ThrowOnFail
Throw a <xref href="Hiero.ContractException" data-throw-if-not-resolved="false"></xref> exception if the query
call returns a code other than success. Default is true to maintain
backwards compatibility. If set to false, the
<xref href="Hiero.ContractCallResult" data-throw-if-not-resolved="false"></xref> will be returned without an exception.
The exception returned also includes the contract call result.
Default is
true
.
Declaration
public bool ThrowOnFail { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |