A ready-to-go template of cross-chain swap dApp with basic React UI components based on Solana Mobile daApp Scaffold. It provides an interface to connect to locally installed wallet apps and perform cross-chain swaps between them.
This React Native dApp is only fully functional on Android.
- Mayan Swap SDK for getting quotes and executing swaps
- WalletConnect Modal for connecting to EVM wallets
- Mobile Wallet Adapter for connecting to wallets and signing transactions/messages
- web3.js for constructing transactions and an RPC
connection
client.
If you haven't setup a React Native development environment for Android, you'll need to do that first. Follow the Prerequisite Setup Guide.
Follow the guide to make sure you:
- setup your Android and React Native development environment.
- have an Android device or emulator.
- install an MWA compliant wallet app on your device/emulator.
- install a WalletConnect compliant wallet app on your device/emulator.
- Clone the project
git clone https://github.com/mayan-finance/swap-sdk.git
- Install dependencies
yarn install
- Set your WalletConnect project ID
- If you don't have a project ID, create one here
- Set your project ID in
components/DappWalletConnectModal.tsx
- Launch the app on your Android device/emulator
npx react-native run-android
- Connect to an evm wallet app
- For evm wallets this will open WalletConnect modal to connect to a wallet app.
- Connect to a Solana wallet app
- To connect to a solana wallet app, this mobile dApp uses Solana mobile adapter.
- Get a quote
- Uses quote function of Mayan swap SDK to get a quote.
- Execute the swap
- For swaps from Solana to EVM, dApp calls swapFromSolana function and passes the
signSolanaTransaction
param like this:
const mwaSignTransaction = useCallback( async (tx: Transaction) => { return await transact(async (wallet: Web3MobileWallet) => { authorizeSession(wallet); const signedTransactions = await wallet.signTransactions({ transactions: [tx], }); return signedTransactions[0]; }); }, [authorizeSession], );
- To swap from EVM to Solana, use swapFromEvm. For ERC20 tokens make sure user has approved the token transfer before calling this function.
- For swaps from Solana to EVM, dApp calls swapFromSolana function and passes the