Execute a Transfer
Once you have selected a transfer route, you can start the cross-chain transfer.
If you don't already have a transfer 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 sdk.transfer(transferRoute, transferParams)
Receive status updates
Use these events to update your UI with helpful information for your users.
sdk.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;
}