Class CIS4Contract

Defines methods for interacting with CIS4 contracts.

Hierarchy

  • CISContract<Updates, Views, CIS4DryRun>
    • CIS4Contract

Constructors

Properties

contractAddress: ContractAddress
contractName: ContractName
dryRunInstance: CIS4DryRun

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

schema: Record<Updates, string> = ...

Parameter schemas for each CIS4 update entrypoint. These are returned individually when creating update transactions to be used for serializing a corresponding JSON representation of the parameter.

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<Updates>

      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<Updates>

      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<Updates>

      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>

  • Look up an entry in the registry by the public key of its holder.

    Returns

    a corresponding credential entry.

    Parameters

    • credHolderPubKey: string

      public key identifying the credential holder

    • Optional blockHash: BlockHash

      block to perform query at.

    Returns Promise<CredentialEntry>

  • Look up the status of a credential by the public key of its holder.

    Returns

    a corresponding credential status.

    Parameters

    • credHolderPubKey: string

      public key identifying the credential holder

    • Optional blockHash: BlockHash

      block to perform query at.

    Returns Promise<CredentialStatus>

  • 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<Views>

      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>

  • Get the AccountAddress public key of the issuer.

    Returns

    a hex encoded public key.

    Parameters

    • Optional blockHash: BlockHash

      block to perform query at.

    Returns Promise<string>

  • Submit CIS4.registerRevocationKeys update transaction.

    Returns

    The hash of the submitted transaction

    Parameters

    • signer: AccountSigner

      to be used for signing the transaction sent to the node.

    • metadata: ContractTransactionMetadata

      transaction metadata

    • keys: string | string[]

      a single or list of hex encoded public keys to be used for revocation

    • Optional additionalData: string = ''

      any additional data to include

    Returns Promise<TransactionHash>

  • Submit CIS4.removeRevocationKeys update transaction.

    Returns

    The hash of the submitted transaction

    Parameters

    • signer: AccountSigner

      to be used for signing the transaction sent to the node.

    • metadata: ContractTransactionMetadata

      transaction metadata

    • keys: string | string[]

      a single or list of hex encoded public keys to be removed

    • Optional additionalData: string = ''

      any additional data to include

    Returns Promise<TransactionHash>

  • Submit CIS4.revokeCredentialHolder update transaction. The revocation message is set to expire at the same time as the transaction (from metadata.expiry)

    Returns

    The hash of the submitted transaction

    Parameters

    • signer: AccountSigner

      to be used for signing the transaction sent to the node.

    • metadata: ContractTransactionMetadata

      transaction metadata

    • credHolderSigner: Web3IdSigner

      A signer structure for the credential holder

    • nonce: bigint

      the nonce of the owner inside the contract

    • Optional reason: string

      the reason for the revocation

    Returns Promise<TransactionHash>

  • Submit CIS4.revokeCredentialIssuer update transaction.

    Returns

    The hash of the submitted transaction

    Parameters

    • signer: AccountSigner

      to be used for signing the transaction sent to the node.

    • metadata: ContractTransactionMetadata

      transaction metadata

    • credHolderPubKey: string

      the public key of the credential holder (hex encoded)

    • Optional reason: string

      the reason for the revocation

    • Optional additionalData: string = ''

      any additional data to include

    Returns Promise<TransactionHash>

  • Submit CIS4.revokeCredentialOther update transaction. The revocation message is set to expire at the same time as the transaction (from metadata.expiry)

    Returns

    The hash of the submitted transaction

    Parameters

    • signer: AccountSigner

      to be used for signing the transaction sent to the node.

    • metadata: ContractTransactionMetadata

      transaction metadata

    • revokerSigner: Web3IdSigner

      A signer structure for the credential holder

    • credentialPubKey: string

      the public key (hex encoded) for the credential to revoke

    • nonce: bigint

      the nonce of the owner inside the contract

    • Optional reason: string

      the reason for the revocation

    Returns Promise<TransactionHash>

  • Creates a new CIS4Contract 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<CIS4Contract>

  • 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