Class ContractException
Represents an error with a contract query that passed the gateway node pre-check and was processed by the gossip node but did not succeed. It includes additional information returned by the hedera contract virtual machine. Transaction fees will have been spent.
Implements
Inherited Members
Namespace: Hiero
Assembly: Hiero.dll
Syntax
public sealed class ContractException : Exception, ISerializable
Remarks
Contract exceptions are generally permanent — they represent EVM-level failures (revert, out-of-gas, invalid opcode) that will produce the same result if retried with identical inputs.
Inspect CallResult for EVM-level details: the revert reason string (if the contract emitted one), gas consumption, and any events that fired before the revert. The Status property carries the Hedera-level response code (e.g. ContractRevertExecuted).
For InsufficientGas, increase the
Gas property on your QueryContractParams and
retry. For other codes, review the contract's Solidity logic and the
inputs that caused the revert. Only contract queries raise this
exception; a CallContractParams transaction that fails
raises TransactionException instead.
When using QueryContractParams, you can suppress this
exception by setting ThrowOnFail to
false — the ContractCallResult is then returned
directly so you can inspect the failure without a try/catch.
Properties
| Edit this page View SourceCallResult
The results returned from the failed call to the smart contract virtual machine.
Declaration
public ContractCallResult CallResult { get; }
Property Value
| Type | Description |
|---|---|
| ContractCallResult |
RequiredFee
The cost value from the query's response header. The network sets it only when a cost estimate is requested, so it is normally 0 here; it is not a fee the query needs in order to succeed.
Declaration
public ulong RequiredFee { get; }
Property Value
| Type | Description |
|---|---|
| ulong |
Status
The ResponseCode the node returned for the contract query (e.g. ContractRevertExecuted).
Declaration
public ResponseCode Status { get; }
Property Value
| Type | Description |
|---|---|
| ResponseCode |
TransactionId
The TransactionId ID generated by the library (or client code) identifying the request.
Declaration
public TransactionId TransactionId { get; }
Property Value
| Type | Description |
|---|---|
| TransactionId |