A factory class for deploying smart contracts to a blockchain using a ThorClient.

Type Parameters

  • TAbi extends Abi

Constructors

  • Initializes a new instance of the ContractFactory class.

    Type Parameters

    • TAbi extends Abi

    Parameters

    • abi: Abi

      The Application Binary Interface (ABI) of the contract, which defines the contract's methods and events.

    • bytecode: string

      The compiled bytecode of the contract, representing the contract's executable code.

    • signer: VeChainSigner

      The signer used for signing transactions during contract deployment, ensuring the deployer's identity.

    • contractsModule: ContractsModule

      An instance of the module to interact with the blockchain.

    Returns ContractFactory<TAbi>

Properties

contractsModule: ContractsModule

Methods

  • Initiates the deployment of a smart contract.

    This method performs several steps to deploy a smart contract:

    1. Builds a transaction clause for deploying the contract.
    2. Estimates the gas cost required for the transaction.
    3. Constructs the transaction body with the estimated gas cost.
    4. Signs the transaction using the provided signer.
    5. Sends the signed transaction to the blockchain.

    Parameters

    • OptionaldeployParams: DeployParams

      (Optional) parameters for contract deployment.

    • Optionaloptions: ContractTransactionOptions

      (Optional) transaction options, such as gas limit.

    Returns Promise<ContractFactory<TAbi>>

    A promise that resolves to the instance of ContractFactory, allowing for fluent chaining of further actions or queries.

    Throws an error if any step in the deployment process fails.

  • Waits for the completion of a contract deployment transaction.

    This method checks for the presence of a deployed transaction result and then waits for the transaction to be processed. Upon successful processing, it constructs and returns a new Contract instance based on the transaction receipt.

    Returns Promise<Contract<TAbi>>

    A promise that resolves to a Contract instance once the deployment transaction is completed.