CCC Docs
    Preparing search index...

    Class FeePayerFromAddressAbstract

    A fee payer that uses addresses to find cells and complete transactions.

    Hierarchy (View Summary)

    Index
    client_: Client

    The client used to interact with the CKB network.

    • 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

      • txLike: TransactionLike

        The transaction to complete the fee for.

      • change: {} & { codeHash: BytesLike; hashType: HashTypeLike; args: BytesLike }

        The lock script for the change output cell.

      • Optionaloptions:
            | {
                feeRate?: NumLike;
                feeRateBlockRange?: NumLike;
                maxFeeRate?: NumLike;
            } & {
                filter?: ClientCollectableSearchKeyFilterLike;
                shouldAddInputs?: boolean;
            }
            | null

        Optional configuration for completing the fee.

        • { feeRate?: NumLike; feeRateBlockRange?: NumLike; maxFeeRate?: NumLike } & {
              filter?: ClientCollectableSearchKeyFilterLike;
              shouldAddInputs?: boolean;
          }
          • OptionalfeeRate?: NumLike

            The fee rate to use. If provided, the fee payer will not fetch the fee rate from the client.

          • OptionalfeeRateBlockRange?: NumLike

            The block range to use for calculating the fee rate.

          • OptionalmaxFeeRate?: NumLike

            The maximum allowed fee rate.

          • Optionalfilter?: ClientCollectableSearchKeyFilterLike

            The filter to use when searching for cells.

          • OptionalshouldAddInputs?: boolean

            Whether to add inputs automatically to cover the fee. Defaults to true.

        • null

      Returns Promise<FeePayerCompleteFeeResult<FeePayerCompleteInputsContext>>

      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:
            | {
                feeRate?: NumLike;
                feeRateBlockRange?: NumLike;
                maxFeeRate?: NumLike;
            } & {
                filter?: ClientCollectableSearchKeyFilterLike;
                shouldAddInputs?: boolean;
            }
            | null

        Optional configuration for completing the fee.

        • { feeRate?: NumLike; feeRateBlockRange?: NumLike; maxFeeRate?: NumLike } & {
              filter?: ClientCollectableSearchKeyFilterLike;
              shouldAddInputs?: boolean;
          }
          • OptionalfeeRate?: NumLike

            The fee rate to use. If provided, the fee payer will not fetch the fee rate from the client.

          • OptionalfeeRateBlockRange?: NumLike

            The block range to use for calculating the fee rate.

          • OptionalmaxFeeRate?: NumLike

            The maximum allowed fee rate.

          • Optionalfilter?: ClientCollectableSearchKeyFilterLike

            The filter to use when searching for cells.

          • OptionalshouldAddInputs?: boolean

            Whether to add inputs automatically to cover the fee. Defaults to true.

        • null

      Returns Promise<FeePayerCompleteFeeResult<FeePayerCompleteInputsContext>>

      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
      );
    • Gets an array of addresses associated with the signer as strings.

      Returns Promise<string[]>

      A promise that resolves to an array of addresses as strings.

    • Gets the recommended Address object for the signer.

      Parameters

      • Optional_preference: unknown

        Optional preference parameter.

      Returns Promise<Address>

      A promise that resolves to the recommended Address object.

    • Gets the recommended address for the signer as a string.

      Parameters

      • Optionalpreference: unknown

        Optional preference parameter.

      Returns Promise<string>

      A promise that resolves to the recommended address as a string.