Show / Hide Table of Contents

Class CreateContractExtensions

Extension methods for creating smart contracts.

Inheritance
object
CreateContractExtensions
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Hiero
Assembly: Hiero.dll
Syntax
public static class CreateContractExtensions

Methods

| Edit this page View Source

CreateContractAsync(ConsensusClient, CreateContractParams, Action<IConsensusContext>?)

Creates a new contract instance with the given create parameters.

Declaration
public static Task<CreateContractReceipt> CreateContractAsync(this ConsensusClient client, CreateContractParams createParameters, Action<IConsensusContext>? configure = null)
Parameters
Type Name Description
ConsensusClient client

The Consensus Node Client executing the contract create.

CreateContractParams createParameters

Details regarding the contract to instantiate.

Action<IConsensusContext> configure

Optional callback method providing an opportunity to modify the execution configuration for just this method call. It is executed prior to submitting the request to the network.

Returns
Type Description
Task<CreateContractReceipt>

A transaction receipt with a description of the newly created contract and receipt information.

Examples

Deploy from bytecode already uploaded to the file service:

// Deploy from bytecode previously uploaded to the file service. Use
// this path for large contracts that exceed the transaction size
// limit. Bytecode must be stored as hex-encoded text, not raw bytes.
var receipt = await client.CreateContractAsync(new CreateContractParams
{
    File = bytecodeFile,
    Administrator = adminEndorsement,
    Gas = 500_000,
    ConstructorArgs = new object[] { "initial" },
    RenewPeriod = TimeSpan.FromDays(90)
});
Console.WriteLine($"Contract: {receipt.Contract}");
Exceptions
Type Condition
ArgumentOutOfRangeException

If required arguments are missing.

InvalidOperationException

If required context configuration is missing.

PrecheckException

If the gateway node rejected the request upon submission.

ConsensusException

If the network was unable to come to consensus before the duration of the transaction expired.

TransactionException

If the network rejected the create request as invalid or had missing data.

  • Edit this page
  • View Source
In this article
Back to top .NET Client Library for Hiero Network and Hedera Hashgraph