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
  1. EMBEDDED WALLET SDK
  2. Quickstart
  3. For Web Apps
  4. Version 1

Get Started on zkSync Era

Install Ramper SDK

npm i @ramper/zksync

or

yarn add @ramper/zksync

User signup & login

import {
  init,
  AUTH_PROVIDERS,
  CHAIN,
  THEME,
  WALLET_PROVIDER,
  SUPPORTED_ZKSYNC_ERA_NETWORKS
} from '@ramper/zksync'
import { getWalletModel, User } from '@ramper/core'

init({
  appName: 'zKsync Test App',
  authProviders: [
    AUTH_PROVIDER.GOOGLE,
    AUTH_PROVIDER.FACEBOOK,
    AUTH_PROVIDER.TWITTER,
    AUTH_PROVIDER.APPLE,
    AUTH_PROVIDER.EMAIL
  ],
  walletProviders: [WALLET_PROVIDER.METAMASK],
  network: SUPPORTED_ZKSYNC_ERA_NETWORKS.MAINNET,
  theme: THEME.DARK,
})

const signInResult = await signIn()

Calling await signIn(walletToUse) launch the log in dialog and return a signInResult when the user successfully logs in or connects an account

Get logged-in user

import { getUser } from '@ramper/zksync'

const user = getUser()

Send Token

The following code demonstrates how to send a token from a wallet belonging to the signed in user or a connected wallet.

import { sendToken } from '@ramper/zksync'

try {
  const isSuccess = await sendToken({
    to: '0xa419dfa199Df8651c3f4476546AF5E4CC4E0F73F',
    value: '0.000001',
    network: 'mainnet'
  })
  console.log('sendToken result: ', isSuccess)
} catch (e) {
  console.error(e)
}

Get ethers.js compatible signer

signTransaction, signMessage and sendTransaction functions are implemented

import { sendTransaction, signTransaction, signMessage } from '@ramper/zksync'

try {
  sendTransaction({
    from: wallet?.publicKey as string,
    data: '0x',
    gasLimit: gasLimit.toString(),
    nonce,
    to: transaction.receiver,
    value: transaction.amount,
  })
  
  signTransaction({
    from: wallet?.publicKey as string,
    data: '0x',
    gasLimit: gasLimit.toString(),
    nonce,
    to: transaction.receiver,
    value: transaction.amount,
  })
  
  signMessage(message)
} catch (e) {
  console.log(e)
}

We highly recommend you use Promise for the fields that need network access to be determined, such as nonce and gasLimit, etc.

If sendTransaction is triggered by a button, for example, and you perform all the accesses before actually calling sendTransaction, we've noticed the popup window for the user confirmation can be blocked by Safari.

Sign out

Users can log out or disconnect their wallet with:

import { signOut } from '@ramper/zksync'

await signOut()

Yup, it really is just that easy!

If there's any feature you would like to see or design patterns you would like for the Ramper team to adopt, come chat with us.

Last updated 1 year ago

Once you have obtained a Signer, you can use the familiar ethers.js functions to write your DApp. See for reference if you aren't already familiar with ethers.js

NPM Source:

🔐
Signers
https://www.npmjs.com/package/@ramper/zksync