Appearance
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
Initialize the TradeCms Instance:
- Use the
TradeCms
class from theskc-trade-sdk
to create an instance of the CMS.
javascriptimport { TradeCms } from "skc-trade-sdk"; const cms = new TradeCms("https://example.com");
- Use the
Create the Sales Order:
- Use the
createSalesOrder
method from theTradeCms
instance to create a new sales order.
javascriptconst 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.
- Use the
Retrieving the Status of an Existing Sales Order
Initialize the SalesOrderContract Instance:
- Use the
SalesOrderContract
class from theskc-sdk
to create an instance of the sales order contract.
javascriptimport { 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");
- Use the
Fetch the Sales Order Status:
- Use the
getSalesOrderStatus
method from theSalesOrderContract
instance to retrieve the status of the sales order.
javascriptconst status = await salesOrderContract.getSalesOrderStatus();
This method returns the status of the sales order as a string.
- Use the
Retrieving the Details of an Existing Sales Order
- Fetch the Sales Order Details:
- Use the
getDetails
method from theSalesOrderContract
instance to retrieve detailed information about the sales order.
javascriptThis method returns a detailed summary of the sales order, including its associated metadata and state.const details = await salesOrderContract.getDetails();
- Use the
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.