Ramper Documentation
  • 🌟WELCOME
  • 👨‍💻Developer Guide
    • Developer Dashboard
  • 🔐EMBEDDED WALLET SDK
    • Quickstart
      • For Web Apps
        • Multichain Supported
          • Wallet Integration
          • Approve NFT
          • Approve Token
          • Sign Typed
        • Get Started on Viction
      • For Unity Apps
      • For Telegram Mini Apps
        • Set up Telegram bot
        • Implement Ramper Telegram SDK
      • For React Native Apps
        • Installation
        • Getting Started
        • Wallet Integration
        • Sign Typed
        • Approve
    • Terms & Conditions
    • Privacy Policy
  • 💜RAMPER WALLET
    • About Ramper Wallet
    • 📖User Guides
      • Authentication
      • How to send NFTs
      • How to sign in to a new account
      • Wallet settings
      • How to Send & Receive tokens
      • How to add custom tokens
      • Manage Tokens
      • General settings
      • How to send assets via email
      • How to use Vault
      • How to send assets via OneID
      • How to migrate accounts from Old version to New version
    • ❓User FAQs
      • Which networks are supported on Ramper?
      • What social accounts can I use to log in to Ramper?
      • What is the difference between a Password and a Passphrase?
      • Zero-gas transactions
      • Does Ramper hold my funds?
      • Can I import my wallet from Ramper to another Web3 wallet?
      • Can I import my wallet to Ramper?
      • Why can't I see my assets?
      • What is gas fee?
      • Can I get my assets back if I send them to the wrong addresses?
      • I forgot the password of my social accounts. How can I access my funds on Ramper?
      • What happens if my social account is compromised?
      • Can I recover my wallet if I lose my social account?
      • Can I change the email that is associated with my wallet address?
      • I can't find the answer to my question. How can I get support?
      • What is a Protected Account?
      • I forgot the PIN code to log in to Ramper Wallet. How can I access my funds?
      • Which email domains are blocked?
    • Ramper Wallet (Extension) Integration
      • EVM Dapp Integration
      • Sei Dapp Integration
    • Privacy Policy
    • Terms of Service
  • 💸NFT CHECKOUT SDK
    • About Ramper NFT Checkout
    • Get Started on EVM
    • Get Started on NEAR
    • Setting Up Your Collection
    • Moving Your Collection to Production
    • Purchase History
    • Terms of Service
    • Privacy Policy
  • Import
Powered by GitBook
On this page
  • Step 1
  • Step 2
  • Usage
  • Transactions
  • Deserialize Transaction
  1. EMBEDDED WALLET SDK
  2. Quickstart
  3. For Web Apps
  4. Version 1
  5. CONNECT MOBILE SDK

React Native EVM

The @ramper/react-native-evm package works in conjunction with the @ramper/react-native-core package. This package works with ethers.js and is responsible for handling all EVM-related peculiarities in order to interact with an Ethereum-based wallet.

npm

$ npm install @ramper/react-native-evm react-native-get-random-values

yarn

$ yarn add @ramper/react-native-evm react-native-get-random-values

Step 1

$ cd ios && pod install

Step 2

You will need to register react-native-get-random-values and @ethersproject/shims in the entry file of your application, such as index.js:

// Import the crypto getRandomValues shim (**BEFORE** the shims)
import 'react-native-get-random-values';

// Import the ethers shims (**BEFORE** ethers)
import '@ethersproject/shims';

Usage

import { ethers } from 'ethers';
import { EtherTx } from '@ramper/react-native-evm';

Transactions

import { Transactions } from '@ramper/react-native-core';

Before you can do transactions you need to create an ethers provider

const provider = ethers.getDefaultProvider(
  `https://polygon-mumbai.g.alchemy.com/v2/${yourApiKey}`
);

Sign Transaction

const value = ethers.utils.parseEther('0.0000001');
try {
  const transaction = await Transactions.signTransaction({
    serializedTx: await EtherTx.serializeTransactionRequest(
      {
        from: 'fromAddress',
        to: 'toAddress',
        value,
      },
      provider
    ),
    network: SUPPORTED_ETHEREUM_NETWORKS.MATICMUM,
    theme: 'light',
  });
  const deserializedTransaction = EtherTx.deserializeTransaction(transaction);=
  
  // broadcast the Signed Transaction to the network:
  const transaction = await provider.sendTransaction(
    deserializedTransaction.transaction
  );
} catch (error) {
  // handle error
}

Sign Typed Data

try {
  const signTypedDataResponse = await Transactions.signTypedData({
    serializedTx: await EtherTx.serializeSignTypedDataRequest(
      {
        name: 'Ether Mail',
        version: '1',
        chainId: 1,
        verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
      },
      {
        Person: [
          { name: 'name', type: 'string' },
          { name: 'wallet', type: 'address' },
        ],
        Mail: [
          { name: 'from', type: 'Person' },
          { name: 'to', type: 'Person' },
          { name: 'contents', type: 'string' },
        ],
      },
      {
        from: {
          name: 'Cow',
          wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
        },
        to: {
          name: 'Bob',
          wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
        },
        contents: 'Hello, Bob!',
      }
    ),
    network: SUPPORTED_ETHEREUM_NETWORKS.MATICMUM,
  });
  const deserializedTypedData = EtherTx.deserializeTransaction(signResponse);
  // handle response
} catch (error) {
  // handle error
}

Sign Message

try {
  const signMessageResponse = await Transactions.signMessage({
    serializedTx: EtherTx.serializeMessage({
      message: 'Hello World',
      method: 'eth_sign',
    }),
    network: SUPPORTED_ETHEREUM_NETWORKS.MATICMUM,
    theme: 'light',
  });
  const deserializedRespone =
    EtherTx.deserializeTransaction(signMessageResponse);
  // handle response
} catch (error) {
  // handle error
}

Personal Sign

try {
  const signPersonalMessageResponse = await Transactions.signMessage({
    serializedTx: EtherTx.serializeMessage({
      message: 'My email is john@doe.com - Thu, 22 Sep 2022 22:45:02 GMT',
      method: 'personal_sign',
    }),
    network: SUPPORTED_ETHEREUM_NETWORKS.MATICMUM,
    theme: 'light',
  });
  const deserializedResponse = EtherTx.deserializeTransaction(
    signPersonalMessageResponse
  );
  // handle response
} catch (error) {
  // handle error
}

Deserialize Transaction

const deserializedTx = EtherTx.deserializeTransaction(serializedTx);

Method Signature:

type DeserializedTx = {
   transaction: string // Signed Transaction
   msgs: any[]
}

Last updated 10 months ago

🔐