Skip to content

Sales Order Creation and Retrieve Status and details

To create a new sales order and retrieve the status and details of an existing sales order, follow these steps:

Creating a New Sales Order

  1. Initialize the TradeCms Instance:

    • Use the TradeCms class from the skc-trade-sdk to create an instance of the CMS.
    javascript
    import { TradeCms } from "skc-trade-sdk";
    const cms = new TradeCms("https://example.com");
  2. Create the Sales Order:

    • Use the createSalesOrder method from the TradeCms instance to create a new sales order.
    javascript
    const salesOrder = await cms.createSalesOrder(
      "MySalesOrder",
      "0xSellerAddress",
      "https://example.com/sales-order",
      "offset-value",
      "Optional memo"
    );

    This method requires parameters such as the name of the sales order, the seller's address, a URI, an offset value, and an optional memo.

Retrieving the Status of an Existing Sales Order

  1. Initialize the SalesOrderContract Instance:

    • Use the SalesOrderContract class from the skc-sdk to create an instance of the sales order contract.
    javascript
    import { SalesOrderContract } from 'skc-sdk';
    const provider = new ethers.JsonRpcProvider("http://localhost:8545");
    const signer = provider.getSigner();
    const salesOrderContract = new SalesOrderContract("0xSalesOrderContractAddress", provider, "http://localhost:8545");
  2. Fetch the Sales Order Status:

    • Use the getSalesOrderStatus method from the SalesOrderContract instance to retrieve the status of the sales order.
    javascript
    const status = await salesOrderContract.getSalesOrderStatus();

    This method returns the status of the sales order as a string.

Retrieving the Details of an Existing Sales Order

  1. Fetch the Sales Order Details:
    • Use the getDetails method from the SalesOrderContract instance to retrieve detailed information about the sales order.
    javascript
    const details = await salesOrderContract.getDetails();
    This method returns a detailed summary of the sales order, including its associated metadata and state.

By following these steps, you can create a new sales order and retrieve the status and details of an existing sales order using the provided SDKs and methods.