run

The run method executes the actions generated by the getActions method to complete the withdrawal transaction. This method sends the transaction to withdraw the funds that were collected in the sale.

Parameters

An IWithdrawConfig object which contains:

  • saleId: The ID of the sale from which to withdraw funds.
  • chainId: The blockchain chain ID where the sale is registered.

Returns

Promise<IWithdrawOutput> - A promise that resolves to the result of the actions execution, including transaction details and the updated context.

Usage

// Step 1: Generate actions for the withdrawal
const actions = sdk.withdrawService.getActions();
actions.on('nextAction', (state) => {
  console.log('Current action state:', state);
});

// Step 2: Prepare the configuration for the withdrawal
const withdrawConfig = {
  saleId: 1, // ID of the sale
  chainId: 1, // ID of the blockchain network
};

// Step 3: Execute the actions to complete the withdrawal
try {
  const result = await actions.run(withdrawConfig);
  console.log('Withdrawal completed successfully:', result);
} catch (error) {
  console.error('Error during withdrawal:', error);
}