Skip to content

mayan-finance/react-native-scaffold

Repository files navigation

Cross-chain Swap React Native dApp Scaffold

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.

Featured Libarires

Scaffold dApp Screenshot 1 Scaffold dApp Screenshot 2 Scaffold dApp Screenshot 3

Prerequisites

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.

Usage

  1. Clone the project
    • git clone https://github.com/mayan-finance/swap-sdk.git
  2. Install dependencies
    • yarn install
  3. Set your WalletConnect project ID
  4. Launch the app on your Android device/emulator
    • npx react-native run-android

Flow

  1. Connect to an evm wallet app
    • For evm wallets this will open WalletConnect modal to connect to a wallet app.
  2. Connect to a Solana wallet app
    • To connect to a solana wallet app, this mobile dApp uses Solana mobile adapter.
  3. Get a quote
  4. 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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors