Swing Points Program is Live 🚀 Learn More →

Execute a Staking Transaction

Once you have selected a route, you can execute your staking transaction.

If you don't already have a route, follow these steps.

Start the transfer

Use the same transfer parameters you used when finding a route. This will handle the entire transfer process for you, including prompting the wallet for any required actions.

await swingSDK.transfer(transferRoute, transferParams);

Receive status updates

Use these events to update your UI with helpful information for your users.

swingSDK.on('TRANSFER', (transfer) => {
  switch (transfer.status) {
    case 'PENDING':
      console.log(`Creating a transaction for the ${transfer.step} step`);
      break;
    case 'CHAIN_SWITCH_REQUIRED':
      // Handle switching chains or alert the user to do it manually
      break;
    case 'ACTION_REQUIRED':
      console.log('Please complete the required action within your connected wallet');
      break;
    case 'CONFIRMING':
      console.log(`Waiting for the transaction from the ${transfer.step} step to complete`);
      break;
    case 'SUCCESS':
      console.log(`Transfer has completed the ${transfer.step} step`);
      break;
    case 'FAILED':
      console.log(`Transfer failed at the ${transfer.step} step:`, transfer.error);
      break;
  }