run

The run method executes the set of actions generated by the getActions method using the client-defined traits. This method involves sending transactions to the blockchain and performing other necessary operations to fractionalize the assets in the market based on the provided configuration.

Parameters

  • config (IFractionalizeConfig): An object that contains the configuration for the fractionalization process. This configuration includes:
    • marketId: The market's unique identifier.
    • values: The market's fraction values, defined by the client.
    • paymentTokenId: The ID of the payment token.
    • pricePerFraction: The price of each fraction.
    • metadata: Metadata related to the sale (e.g., sale name, description).
    • chainId: The blockchain chain ID (deprecated, will be removed when off-chain assets have a chainId).

Returns

Promise<IFractionalizeOutput<Traits>>: A promise that resolves to the result of the actions execution. This includes transaction details and any output data from the fractionalization process, such as transaction receipts or emitted events.

Usage Example

// Step 1: Define the traits for the market's fractionalization
const traits = {
  wrappedAssetKind: MarketTraitEnum.WRAPPED_ASSET_KIND,
  fractionAssetKinds: MarketTraitEnum.FRACTION_ASSET_KINDS,
  time: MarketTraitEnum.TIME,
  capitalization: MarketTraitEnum.CAPITALISATION,
};

// Step 2: Call getActions to generate the actions
const actions = sdk.FractionalizeService.getActions(traits);

// Step 3: Prepare the configuration for fractionalization
const config = {
  marketId: 123,
  values: marketFractionValues, // Assume marketFractionValues is predefined
  paymentTokenId: 1,
  pricePerFraction: BigInt(100),
  metadata: saleMetadata, // Assume saleMetadata is predefined
  chainId: 1,
};

// Step 4: Execute the actions
try {
  const result = await actions.run(config);
  console.log('Fractionalization successful:', result);
} catch (error) {
  console.error('Error during fractionalization:', error);
}