Class CreateContractParams
Smart Contract creation properties.
Inherited Members
Namespace: Hiero
Assembly: Hiero.dll
Syntax
public sealed class CreateContractParams : TransactionParams<CreateContractReceipt>
Examples
Deploy a small contract from inline bytecode. For contracts too large to
fit in a single transaction, upload the bytecode via the file service
first and set File instead of ByteCode:
// Deploy a small contract from inline bytecode. For contracts too
// large to fit in a single transaction, upload the bytecode to the
// file service first and set `File` instead of `ByteCode`. An
// Administrator key makes the contract upgradable; omit it to make
// the contract immutable.
var receipt = await client.CreateContractAsync(new CreateContractParams
{
ByteCode = bytecode,
Administrator = adminEndorsement,
Gas = 300_000,
InitialBalance = 0,
ConstructorArgs = Array.Empty<object>(),
RenewPeriod = TimeSpan.FromDays(90),
Memo = "Deployed via Hiero SDK"
});
Console.WriteLine($"Contract: {receipt.Contract}");
Properties
| Edit this page View SourceAdministrator
An optional endorsement that can be used to modify the contract details.
If left null, the contract is immutable once created.
Declaration
public Endorsement? Administrator { get; set; }
Property Value
| Type | Description |
|---|---|
| Endorsement |
AutoAssociationLimit
The maximum number of token or NFTs that this contract may be implicitly associated with (by means of being made a treasury or other related actions).
Declaration
public int AutoAssociationLimit { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
Defaults to zero.
ByteCode
The binary byte code representing the contract. This field must
be left
Empty
if the
File
property is specified. The byte code must fit within the size of a hapi transaction, or the
File
option of uploading a larger contract to a file first must be utilized.
Declaration
public ReadOnlyMemory<byte> ByteCode { get; set; }
Property Value
| Type | Description |
|---|---|
| ReadOnlyMemory<byte> |
CancellationToken
Optional Cancellation token that can interrupt the contract creation.
Declaration
public CancellationToken? CancellationToken { get; set; }
Property Value
| Type | Description |
|---|---|
| CancellationToken? |
ConstructorArgs
The arguments to pass to the smart contract constructor method.
Declaration
public object[] ConstructorArgs { get; set; }
Property Value
| Type | Description |
|---|---|
| object[] |
DeclineStakeReward
Indicate to the network that this contract does not wish to receive any earned staking rewards.
Declaration
public bool DeclineStakeReward { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
File
The address of the file containing the bytecode for the contract.
The bytecode in the file must be encoded as a hexadecimal string
representation of the bytecode in the file (not directly as the
bytes of the bytecode).
Typically this field is used for contracts that are so large
that they can not be represented in the transaction size
limit, otherwise the
ByteCode
property can be set instead, avoiding the extra fees of uploading a file.
This field must be set to
None
or
null
if the
ByteCode
property is set.
Declaration
public EntityId File { get; set; }
Property Value
| Type | Description |
|---|---|
| EntityId |
Gas
Maximum gas to pay for executing the constructor method.
Declaration
public long Gas { get; set; }
Property Value
| Type | Description |
|---|---|
| long |
Hooks
Optional list of hooks to create on the contract immediately after it is created.
Declaration
public IEnumerable<HookMetadata>? Hooks { get; set; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<HookMetadata> |
InitialBalance
The initial value in tinybars to send to this contract instance.
If the contract is not payable, providing a non-zero value will result
in a contract create failure.
Declaration
public long InitialBalance { get; set; }
Property Value
| Type | Description |
|---|---|
| long |
Memo
Short description of the contract, limit to 100 bytes.
Declaration
public string? Memo { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
RenewAccount
Optional address of the account supporting the auto renewal of the contract at expiration time. The contract lifetime will be extended by the RenewPeriod at expiration time if this account contains sufficient funds. The private key associated with this account must sign the transaction if RenewAccount is specified.
Declaration
public EntityId? RenewAccount { get; set; }
Property Value
| Type | Description |
|---|---|
| EntityId |
Remarks
If specified, an Administrator Endorsement must also be specified.
RenewPeriod
The renewal period for maintaining the contract bytecode and state.
The contract instance will be charged at this interval as appropriate.
Declaration
public TimeSpan RenewPeriod { get; set; }
Property Value
| Type | Description |
|---|---|
| TimeSpan |
Signatory
Additional private key, keys or signing callback method required to create this contract. Typically matches the Administrator endorsement assigned to this new contract.
Declaration
public Signatory? Signatory { get; set; }
Property Value
| Type | Description |
|---|---|
| Signatory |
Remarks
Keys/callbacks added here will be combined with those already identified in the client object's context when signing this transaction to change the state of this account.
StakedNode
The funds of this contract will be staked to the gossip node with the given ID.
Declaration
public long? StakedNode { get; set; }
Property Value
| Type | Description |
|---|---|
| long? |
Remarks
Can not be set if the
StakingProxy
property is set.
StakingProxy
The funds of this contract will be staked to the node that this contract is staked to and the specified account will receive the earned reward.
Declaration
public EntityId? StakingProxy { get; set; }
Property Value
| Type | Description |
|---|---|
| EntityId |
Remarks
This value must be set to
null
or
<pre><code class="lang-csharp">None</code></pre>
if the
StakedNode
property is set.