Skip to content

Payment Commitment Creation and Fetch its state, details, refutation info

To create a new payment commitment, check its state and details, and understand the refutation process, you can use the following methods:

Creating a New Payment Commitment

To create a new payment commitment, you should use the createPaymentCommitment method from the TradeCms class. This method is specifically designed for creating payment commitments and should be used instead of methods from PaymentCommitmentContract or PaymentCommitmentFactoryContract:

javascript
import { TradeCms } from "skc-trade-sdk";
const cms = new TradeCms("https://example.com");
const paymentCommitment = await cms.createPaymentCommitment(
  "MyPaymentCommitment",
  "offset-value",
  "https://example.com/commitment",
  "0xCommitterAddress",
  "Optional memo"
);

Checking the State and Details of a Payment Commitment

To check the state and details of a payment commitment, you can use the following methods from the PaymentCommitmentContract class:

  1. Get Commitment State:

    javascript
    const state = await contract.getCommitmentState();

    This method retrieves the commitment state as a human-readable string.

  2. Get Details:

    javascript
    const details = await contract.getDetails();

    This method retrieves all relevant details of the payment commitment.

Understanding the Refutation Process

The refutation process for a payment commitment involves several methods to retrieve and process refutation-related information:

  1. Discharge Refutation Details:

    javascript
    const details = await contract.dischargeRefutationDetails();

    This method retrieves details of refutation events.

  2. Refutations Timeline:

    javascript
    const timeline = await contract.refutationsTimeline();

    This method fetches the refutation timeline based on events.

  3. Get Refutation Window:

    javascript
    const windowDuration = await contract.getRefutationWindow();

    This method retrieves the refutation window duration as a string.

By using these methods, you can effectively create a new payment commitment, check its state and details, and understand the refutation process associated with it.