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
  • Connect
  • The easiest way to connect to Ramper Wallet
  • To detect Ramper Wallet Extension
  • To connect Ramper Wallet Extension
  • To disconnect Ramper Wallet Extension
  • To experience functions
  • Account
  • Sign Transaction
  • Transfer
  • Decrypt & Encrypt
  1. RAMPER WALLET
  2. Ramper Wallet (Extension) Integration

EVM Dapp Integration

Integration

Welcome to Ramper Wallet Extension Developer Guide. This documentation contains guides for developers to get started developing Ramper Wallet on EVM networks

Connect

The easiest way to connect to Ramper Wallet

Check if the provider is window.ramper2, if not, please replace it with the exclusive Ramper Wallet provider window.ramper2.

For example, see below:

function getProvider() {
  const provider = window.ramper2;
  if (!provider) {
    return window.open('https://https://chrome.google.com/webstore/detail/ramper-wallet/nbdhibgjnjpnkajaghbffjbkcgljfgdi?hl=vi');
  }
  return provider;
}

ChainID:

Hex

Decimal

Network

0x1

1

Ethereum (Mainnet)

0x58

88

TomoChain (Mainnet)

0x38

56

BNB Smart Chain (Mainnet)

0x89

137

Polygon (Mainnet)

Use eth_chainId or net_version to return the current network/chain ID

To detect Ramper Wallet Extension

if(window.ramper2){ console.log('Ramper Extension is installed!'); }

To connect Ramper Wallet Extension

To connect Ramper Extension means to access the user's [blockchain - like Ethereum] account(s).


Access a user's accounts

We recommend providing a button to allow users to connect Ramper Wallet to your dapp. Selecting this button should call eth_requestAccounts to access the user's accounts.

//Alias for connection
window.ramper2.provider.request({method: 'eth_requestAccounts'});​

Use the eth_accounts RPC method to handle user accounts. Listen to the accountsChanged provider event to be notified when the user changes accounts.

// Connect & get accounts
window.ramper2.provider.request({method: 'eth_accounts'});

Switch chain

Requests that the Ramper Extension switches its active Ethereum chain.

window.ramper2.provider.request({
  "method": "wallet_switchEthereumChain",
  "params": [
    {
      "chainId": "0x58"
    }
  ]
});

To disconnect Ramper Wallet Extension

To disconnect Ramper Extension, please use:

window.ramper2.provider.disconnect()

To experience functions

Once your account is connected, let's start experiencing more functions.β€Œ

Account

How to get Current Account

return Promise<Array[String]>

  • If the wallet can not be found, return [] instead of throw Error

window.ramper2.provider.request({ method: 'eth_accounts' }).then(accounts => {
  if (accounts[0]) {
    // Do something with accounts
  } else {
    // Wallet not found
  }
})

Sign Transaction

Important

eth_signTypedData_v1, and eth_signTypedData_v3 are deprecated. We highly recommend users use eth_signTypedData_v4 or personal_sign.

Personal_sign

personal_sign provides a simple means to request signatures that are human-readable and don't require efficient processing on-chain. It's commonly used for signature challenges authenticated on a web server.

Ramper Wallet implements both personal_sign and eth_sign. You might need to check what method your supported signers use for a given implementation.

method: 'personal_sign', params: [msg, from],

eth_signTypedData_v4

const msgParams = JSON.stringify({
    domain: {
      chainId: 0x,
      name: 'Ether Mail',
      verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
      version: '1',
    },

    message: {
      contents: 'Hello, Bob!',
      attachedMoneyInEth: 4.2,
      from: {
        name: 'Cow',
        wallets: [
          '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
          '0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF',
        ],
      },
      to: [
        {
          name: 'Bob',
          wallets: [
            '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
            '0xB0BdaBea57B0BDABeA57b0bdABEA57b0BDabEa57',
            '0xB0B0b0b0b0b0B000000000000000000000000000',
          ],
        },
      ],
    },
    
    primaryType: 'Mail',
    types: {
      EIP712Domain: [
        { name: 'name', type: 'string' },
        { name: 'version', type: 'string' },
        { name: 'chainId', type: 'uint256' },
        { name: 'verifyingContract', type: 'address' },
      ],
      Group: [
        { name: 'name', type: 'string' },
        { name: 'members', type: 'Person[]' },
      ],
      Mail: [
        { name: 'from', type: 'Person' },
        { name: 'to', type: 'Person[]' },
        { name: 'contents', type: 'string' },
      ],
      Person: [
        { name: 'name', type: 'string' },
        { name: 'wallets', type: 'address[]' },
      ],
    },
  ;

Note:

Gas limit​ : is an optional parameter, since Ramper Wallet automatically calculates a reasonable gas price.

chainid: The chain ID is derived from the user's current selected network at window.ramper2.provider.net_version.

personal_ecRecover

personal_ecRecover returns the address associated with the private key that was used to calculate a signature.

method: 'personal_ecRecover', params: [message, signature],

Transfer

This method requires that the user has granted permission to interact with their account first, so please make sure to call eth_requestAccounts or wallet_requestPermissions first.

eth_sendTransaction

return Promise<hash>

window.ramper2.provider.request({
  method: 'eth_sendTransaction',
  params: [
    {
      from: 'string',
      to: 'string',
      gas: 'string',
      gasPrice: 'string',
      value: 'string',
      data: 'string',
      nonce: 'string'
    }
  ]
})

Decrypt & Encrypt

eth_decrypt

Requests that Ramper Wallet decrypt the specified encrypted message.

  • The message must have been encrypted using the public encryption key of the specified Ethereum address.

return Promise<string>

window.ramper2.provider.request({
  method: 'eth_decrypt',
  params: [encryptedMessage, accounts[0]],
  })
   .then((decryptedMessage) =>
    console.log('The decrypted message is:', decryptedMessage)
  )
  .catch((error) => console.log(error.message));
})

eth_getEncryptionPublicKey

Requests that the user share their public encryption key. Returns a public encryption key, or rejects if the user denies the request.

return Promise<string>- The public encryption key of the Ethereum account whose encryption key should be retrieved

let encryptionPublicKey
window.ramper2.provider.request({
  method: 'eth_getEncryptionPublicKey',
  params: [accounts[0]], // you must have access to the specified account
  })
  .then((result) => {
    encryptionPublicKey = result;
  })
  .catch((error) => {
    if (error.code === 4001) {
     
      // EIP-1193 userRejectedRequest error
      console.log("We can't encrypt anything without the key.");
    } else {
      console.error(error);
    }
  });

Encrypt

const ethUtil = require('ethereumjs-util');
const encryptedMessage = ethUtil.bufferToHex(

  Buffer.from(
    JSON.stringify(
      sigUtil.encrypt(
        {
          publicKey: encryptionPublicKey,
          data: 'hello world!,
          version: 'x25519-xsalsa20-poly1305',
        }
      )
    ),
    'utf8'
  )
);

List of events

Currently, we only support some action events from the wallet extension

window.ethereum.on('event_name', callback);

​//Example

window.ramper2.provider.on('close', () => window.location.reload());

window.ramper2.provider.on('accountsChanged', () => window.location.reload());

Events

Trigger

accountsChanged

Receive when active account changed in Extension

chainChanged

Receive when active chain changed in Extension

Method

Description

on(event, callback)

Add event listener

off(event, callback)

Remove event listener

PreviousRamper Wallet (Extension) IntegrationNextSei Dapp Integration

Last updated 1 year ago

Handle accounts

eth_signTypedData_v4 offers highly legible signatures that can be processed efficiently on-chain. Adheres to the standard, enabling users to sign typed structured data that can be confirmed on-chain.

πŸ’œ
​
EIP-712