CCC Docs
    Preparing search index...

    Class FeePayer<CollectCapacityOptions, CollectCapacityContext, CompleteFeeOptions>Abstract

    An abstract class representing a fee payer. This class provides methods to complete transaction inputs and fees.

    Type Parameters

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    client_: Client

    The client used to interact with the CKB network.

    Accessors

    Methods

    • Prepares a transaction before signing. This method can be overridden by subclasses to perform any necessary steps, such as adding cell dependencies or witnesses, before the transaction is signed. The default implementation converts the TransactionLike object to a Transaction object without modification.

      Parameters

      Returns Promise<Transaction>

      A promise that resolves to the prepared Transaction object.

      Note that this default implementation does not add any cell dependencies or dummy witnesses. This may lead to an underestimation of transaction size and fees if used with methods like Transaction.completeFee. Subclasses for signers that are intended to sign transactions should override this method to perform necessary preparations.

    • Completes the transaction fee by adding inputs and creating a change output with the specified lock script. This is a convenience method that automatically creates a change cell with the provided lock script when there's excess capacity after paying the transaction fee.

      Parameters

      Returns Promise<FeePayerCompleteFeeResult<CollectCapacityContext>>

      A promise that resolves to the transaction with the fee paid, whether it was modified, and the operation context.

      const changeScript = Script.from({
      codeHash: "0x...",
      hashType: "type",
      args: "0x..."
      });

      const { hasChanged } = await feePayer.completeFeeChangeToLock(
      tx,
      changeScript,
      );
    • Completes the transaction fee by adding excess capacity to an existing output. Instead of creating a new change output, this method adds any excess capacity to the specified existing output in the transaction.

      Parameters

      • txLike: TransactionLike

        The transaction to complete the fee for.

      • index: NumLike

        The index of the existing output to add excess capacity to.

      • Optionaloptions: CompleteFeeOptions

        Optional configuration for completing the fee.

      Returns Promise<FeePayerCompleteFeeResult<CollectCapacityContext>>

      A promise that resolves to the transaction with the fee paid, whether it was modified, and the operation context.

      When the specified output index doesn't exist.

      // Add excess capacity to the first output (index 0)
      const { hasChanged } = await feePayer.completeFeeChangeToOutput(
      tx,
      0, // Output index
      );