Appearance
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:
Get Commitment State:
javascriptconst state = await contract.getCommitmentState();
This method retrieves the commitment state as a human-readable string.
Get Details:
javascriptconst 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:
Discharge Refutation Details:
javascriptconst details = await contract.dischargeRefutationDetails();
This method retrieves details of refutation events.
Refutations Timeline:
javascriptconst timeline = await contract.refutationsTimeline();
This method fetches the refutation timeline based on events.
Get Refutation Window:
javascriptconst 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.