Class CIS3Contract

Defines methods for interacting with CIS3 contracts.

Hierarchy

  • CISContract<Update, View, CIS3DryRun>
    • CIS3Contract

Constructors

Properties

contractAddress: ContractAddress
contractName: ContractName
dryRunInstance: CIS3DryRun

The dry-run instance accessible through the CISContract.dryRun dryRun getter

schema: Record<"permit", string> = ...

Parameter schema for the permit CIS3 entrypoint.

Accessors

  • get dryRun(): D
  • A dry-run instance, providing access to methods for performing dry-run invocations of update instructions.

    Returns D

Methods

  • Check if the smart contract instance exists on the blockchain and whether it uses a matching contract name. Optionally a module reference can be provided to check if the contract instance uses this module.

    Throws

    If failing to communicate with the concordium node or if the instance does not exist on chain or fails the checks.

    Parameters

    • Optional options: ContractCheckOnChainOptions = {}

      Options for checking information on chain.

    Returns Promise<void>

  • Creates and sends a contract update transaction with parameter input to entrypoint.

    Throws

    If the query could not be invoked successfully.

    Returns

    The transaction hash of the update transaction

    Type Parameters

    • T

      The type of the input

    Parameters

    • entrypoint: EntrypointName.Type<"permit">

      The name of the receive function to invoke.

    • serializeInput: ((input: T) => ArrayBuffer)

      A function to serialize the input to bytes.

        • (input: T): ArrayBuffer
        • Parameters

          • input: T

          Returns ArrayBuffer

    • metadata: ContractTransactionMetadata

      Metadata to be used for the transaction (with defaults).

    • input: T

      Input for for contract function.

    • signer: AccountSigner

      An object to use for signing the transaction.

    Returns Promise<TransactionHash>

  • Creates a ContractUpdateTransactionWithSchema contract update transaction, holding the necessary parts to sign/submit to the chain.

    Throws

    If the query could not be invoked successfully.

    Returns

    The transaction hash of the update transaction

    Type Parameters

    • T

    Parameters

    • entrypoint: EntrypointName.Type<"permit">

      The name of the receive function to invoke.

    • serializeInput: ((input: T) => ArrayBuffer)

      A function to serialize the input to bytes.

        • (input: T): ArrayBuffer
        • Parameters

          • input: T

          Returns ArrayBuffer

    • metadata: CreateContractTransactionMetadata

      Metadata to be used for the transaction creation (with defaults).

    • input: T

      Input for for contract function.

    Returns ContractUpdateTransaction

  • Creates a ContractUpdateTransactionWithSchema contract update transaction, holding the necessary parts to sign/submit to the chain.

    Throws

    If the query could not be invoked successfully.

    Returns

    The transaction hash of the update transaction

    Type Parameters

    Parameters

    • entrypoint: EntrypointName.Type<"permit">

      The name of the receive function to invoke.

    • serializeInput: ((input: T) => ArrayBuffer)

      A function to serialize the input to bytes.

        • (input: T): ArrayBuffer
        • Parameters

          • input: T

          Returns ArrayBuffer

    • metadata: CreateContractTransactionMetadata

      Metadata to be used for the transaction creation (with defaults).

    • input: T

      Input for for contract function.

    • inputJsonFormatter: ((input: T) => J)

      A function to format the input as JSON format serializable by the contract schema.

        • (input: T): J
        • Parameters

          • input: T

          Returns J

    Returns ContractUpdateTransactionWithSchema<J>

  • Get information on this smart contract instance.

    Throws

    if the InstanceInfo of the contract could not be found.

    Returns

    The instance info.

    Parameters

    • Optional blockHash: BlockHash

      Hash of the block to check information at. When not provided the last finalized block is used.

    Returns Promise<InstanceInfo>

  • Invokes entrypoint view function on contract.

    Throws

    If the query could not be invoked successfully.

    Returns

    The transaction hash of the update transaction

    Type Parameters

    • T

      The type of the input

    • R

      The type the invocation response should be deserialized into.

    Parameters

    • entrypoint: EntrypointName.Type<"supportsPermit">

      The name of the view function to invoke.

    • serializeInput: ((input: T) => ArrayBuffer)

      A function to serialize the input to bytes.

        • (input: T): ArrayBuffer
        • Parameters

          • input: T

          Returns ArrayBuffer

    • deserializeResponse: ((value: string) => R)

      A function to deserialize the value returned from the view invocation.

        • (value: string): R
        • Parameters

          • value: string

          Returns R

    • input: T

      Input for for contract function.

    • Optional blockHash: BlockHash

      The hash of the block to perform the invocation of. Defaults to the latest finalized block on chain.

    Returns Promise<R>

  • Sends a permit update transaction to the network. This is a CIS3 sponsored transaction that allows a sponsor to send a transaction on behalf of a sponsoree.

    Returns

    The hash of the transaction.

    Parameters

    • metadata: ContractTransactionMetadata

      Metadata needed for the transaction creation.

    • params: PermitParam

      The parameters for the permit entrypoint. Includes the signature of the sponsoree, the address of the sponsoree, and the signed message.

    • signer: AccountSigner

      The signer (of the sponsor) to use for the transaction.

    Returns Promise<TransactionHash>

  • Queries the contract to determine if the permit function supports a given entrypoint.

    Returns

    Whether the contract supports the entrypoint.

    Parameters

    • entrypoint: EntrypointName.Type<string>

      The entrypoint to check for support.

    • Optional blockHash: BlockHash

      The hash of the block to perform the invocation of. Defaults to the latest finalized block on chain.

    Returns Promise<boolean>

  • Queries the contract with a list of entrypoints to determine if the permit function supports the given entrypoints. Returns an array of booleans indicating support for each entrypoint.

    Returns

    An array of booleans indicating support for each given entrypoint.

    Parameters

    • entrypoints: EntrypointName.Type<string>[]

      The entrypoint to check for support.

    • Optional blockHash: BlockHash

      The hash of the block to perform the invocation of. Defaults to the latest finalized block on chain.

    Returns Promise<boolean[]>

  • Creates a new CIS3Contract instance by querying the node for the necessary information through the supplied grpcClient.

    Throws

    If InstanceInfo could not be received for the contract, or if the contract name could not be parsed from the information received from the node.

    Parameters

    • grpcClient: ConcordiumGRPCClient

      The client used for contract invocations and updates.

    • contractAddress: ContractAddress

      Address of the contract instance.

    Returns Promise<CIS3Contract>

  • Helper function for getting the name of a contract

    Throws

    if the InstanceInfo of the contract could not be found.

    Returns

    the name of the contract.

    Parameters

    • grpcClient: ConcordiumGRPCClient

      The GRPC client for accessing a node.

    • contractAddress: ContractAddress

      The address of the contract.

    Returns Promise<ContractName>

  • Helper function for getting the InstanceInfo of a contract

    Throws

    if the InstanceInfo of the contract could not be found.

    Returns

    the instance info.

    Parameters

    • grpcClient: ConcordiumGRPCClient

      The GRPC client for accessing a node.

    • contractAddress: ContractAddress

      The address of the contract.

    Returns Promise<InstanceInfo>

Generated using TypeDoc