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
  5. SDK Specifications

Transactions

Send Token

Currently, Ramper SDK supports sendToken which is a simple way to send a token to another address from the current logged in wallet.

const sendToken = async (params: Partial<{
  from: string
  to: string
  value: string
  decimal: number
  symbol: string
  network: string
  theme: string
}>) => Promise<boolean>

Example Usage:

import { sendToken } from '@ramper/ethereum'

await sendToken({
  to: '0xa419dfa199Df8651c3f4476546AF5E4CC4E0F73F',
  value: '0.00001',
  network: 'mainnet'
})

RamperSigner

import { ethers } from 'ethers'

const alchemy = new ethers.providers.AlchemyProvider(80001, 'pEWvHrkSkkyWGZmezdGMk_LjYu8DAx1k')

After the user is logged in through Ramper SDK, you can set up a RamperSigner object with the alchemy provider that will eventually collect the user's authorization to sign the requested transaction.

import { getRamperSigner } from '@ramper/ethereum'

// User must be logged in
const ramperSigner = await getRamperSigner(alchemy)

Sign Transaction

import { TransactionRequest } from '@ethersproject/abstract-provider'

ramperSigner.signTransaction(
    transaction: Deferrable<TransactionRequest>
): Promise<string>

Example usage:

import { getRamperSigner } from '@ramper/ethereum'
import { ethers } from 'ethers'

const alchemy = new ethers.providers.AlchemyProvider(80001, 'pEWvHrkSkkyWGZmezdGMk_LjYu8DAx1k')
const ramperSigner = await getRamperSigner(alchemy)

const value = ethers.utils.parseEther('0.0000001')
const nonce = await alchemy.getTransactionCount('your-wallet-address')
const gasLimit = await alchemy.estimateGas({
  to: '0xa419dfa199Df8651c3f4476546AF5E4CC4E0F73F',
  value: value,
})
const feeData = await alchemy.getFeeData()

try {
    const result = await ramperSigner.signTransaction({
        type: 2,
        from: 'your-wallet-address',
        to: '0xa419dfa199Df8651c3f4476546AF5E4CC4E0F73F',
        value: value,
        chainId: 80001,
        nonce: nonce,
        gasLimit: gasLimit,
        maxFeePerGas: feeData.maxFeePerGas,
        maxPriorityFeePerGas: feeData.maxPriorityFeePerGas,
    })
    console.log('signTransaction result', result)
} catch (e) {
  console.log(e)
}

Send Transaction

import { 
    TransactionRequest, 
    TransactionResponse 
} from '@ethersproject/abstract-provider'

ramperSigner.sendTransaction(
    transaction: Deferrable<TransactionRequest>
): Promise<TransactionResponse>

Example usage:

import { getRamperSigner } from '@ramper/ethereum'
import { ethers } from 'ethers'

const alchemy = new ethers.providers.AlchemyProvider(80001, 'pEWvHrkSkkyWGZmezdGMk_LjYu8DAx1k')
const ramperSigner = await getRamperSigner(alchemy)

const value = ethers.utils.parseEther('0.0000001')
const nonce = await alchemy.getTransactionCount('your-wallet-address')
const gasLimit = await alchemy.estimateGas({
  to: '0xa419dfa199Df8651c3f4476546AF5E4CC4E0F73F',
  value: value,
})
const feeData = await alchemy.getFeeData()

try {
  await ramperSigner.sendTransaction({
    type: 2,
    from: 'your-wallet-address',
    to: '0xa419dfa199Df8651c3f4476546AF5E4CC4E0F73F',
    value: value,
    chainId: 80001,
    nonce: nonce,
    gasLimit: gasLimit,
    maxFeePerGas: feeData.maxFeePerGas,
    maxPriorityFeePerGas: feeData.maxPriorityFeePerGas,
  })
  console.log('sendTransaction result', result)
} catch (e) {
  console.log(e)
}

Sign Message

ramperSigner.signMessage(
    message: Bytes | string
): Promise<string>

Example usage:

import { getRamperSigner } from '@ramper/ethereum'
import { ethers } from 'ethers'

const alchemy = new ethers.providers.AlchemyProvider(80001, 'pEWvHrkSkkyWGZmezdGMk_LjYu8DAx1k')
const ramperSigner = await getRamperSigner(alchemy)

try {
  const message = 'Ramper sign message test'
  const result = await ramperSigner.signMessage(message)
  
  console.log('signMessage result: ', result)
} catch (e) {
  console.log(e)
}

Sign TypedData

import { TypedDataField } from '@ethersproject/abstract-signer'

ramperSigner._signTypedData(
    domain: TypedDataDomain,
    types: Record<string, Array<TypedDataField>>,
    value: Record<string, any>,
  ): Promise<string>

Example usage:

import { getRamperSigner } from '@ramper/ethereum'
import { ethers } from 'ethers'
import { eip712 } from './eip712

const alchemy = new ethers.providers.AlchemyProvider(80001, 'pEWvHrkSkkyWGZmezdGMk_LjYu8DAx1k')
const ramperSigner = await getRamperSigner(alchemy)

try {
  const message = 'Ramper signTypedData test'
  const result = await ramperSigner.signTypedData(
    eip712.example.domain, 
    eip712.example.types, 
    eip712.example.value
  )
  
  console.log('signTypedData result: ', result)
} catch (e) {
  console.log(e)
}

eip712.ts

const example = {
  domain: {
    name: 'Ether Mail',
    version: '1',
    chainId: 1,
    verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
  },

  // The named list of all type definitions
  types: {
    Person: [
      { name: 'name', type: 'string' },
      { name: 'wallet', type: 'address' },
    ],
    Mail: [
      { name: 'from', type: 'Person' },
      { name: 'to', type: 'Person' },
      { name: 'contents', type: 'string' },
    ],
  },

  // The data to sign
  value: {
    from: {
      name: 'Cow',
      wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
    },
    to: {
      name: 'Bob',
      wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
    },
    contents: 'Hello, Bob!',
  },
}

export const eip712 = {
  example,
}

Send Token

Currently, Ramper Connect SDK supports sendToken which is a simple way to send a token to another address from the current logged in wallet.

const sendToken = async (params: Partial<{
  from: string
  to: string
  value: string
  decimal: number
  symbol: string
  network: string
  theme: string
}>) => Promise<boolean>

Example Usage:

import { sendToken } from '@ramper/near'

await sendToken({
  to: '421ccd52db3465153de4591177396dc72e401b0ab1687b8c175491be32fbd148',
  value: '0.01', 
  network: 'testnet'
})

Custom Transactions

import { sendTransaction } from '@ramper/near'
import { transactions } from 'near-api-js'
import { BN } from 'bn.js'

try {
  const actions = [transactions.transfer(new BN(10000000))]
  await sendTransaction({
    transactionActions: [{
      receiverId: '421ccd52db3465153de4591177396dc72e401b0ab1687b8c175491be32fbd148'
      actions: actions
    }],
    network: 'testnet',
  })
} catch (ex) {
  console.error('Transaction failed')
}
type SendTransactionResult = {
  type: 'success' | 'failure' | 'cancel' | 'none'
  txHashes: string[]
  result?: (FinalExecutionOutcome | Error)[] | Error
}

Note. If you sign in with NEAR Wallet, you can get transaction hashes only.

Sign Transaction

const signTransaction = async (params: {
  transaction: Transaction
  network?: NearNetwork
}) => Promise<{
  type: 'success' | 'failure' | 'cancel' | 'none',
  result?: string | Error
}>
import { transactions } from 'near-api-js'

type Transaction = {
  receiverId: string
  actions: transactions.Action[]
}

Example Usage:

import { signTransaction } from '@ramper/near'

try {
  const result = await signTransaction({
    transaction: {
      receiverId: '421ccd52db3465153de4591177396dc72e401b0ab1687b8c175491be32fbd148',
      actions: [transactions.transfer(new BN(10000000))],
    },
  })
  console.log('signTransaction result', result)
} catch (e) {
  console.error(e)
}

Sign Message

const signMessage = async (params: {
  message: Uint8Array
  network?: NearNetwork
}) => Promise<{
  type: TransactionResultType
  result?: Signature | Error
}>

Example Usage:

import { signMessage } from '@ramper/near'

const message = [12, 13, 14, 15]
const messageBuffer = new Uint8Array(message)

try {
  const result = await signMessage({
    message: messageBuffer,
  })
  console.log('signMessage result', result)
} catch (e) {
  console.log(e)
}

Send Token

Currently, Ramper Connect SDK supports sendToken which is a simple way to send a token to another address from the current logged in wallet.

const sendToken: async (params: Partial<{
  from: string
  to: string
  value: string
  decimal: number
  symbol: string
  network: string
  theme: string
  status: WalletStatus
  connectedWallet: ConnectedWallet
}>) => Promise<boolean>

status and connectedWallet are used in case you want to support with Terra Station and Wallet Connect.

import {
  useConnectedWallet,
  useWallet
} from '@terra-money/wallet-provider'

...

const walletToUse = useWallet()
const { status } = walletToUse
const connectedWallet = useConnectedWallet()

Example Usage:

import {
  useConnectedWallet,
  useWallet
} from '@terra-money/wallet-provider'
import { sendToken } from '@ramper/terra'

const walletToUse = useWallet()
const { status } = walletToUse
const connectedWallet = useConnectedWallet()
const toAddress = 'terra123aqd9edra72sehg84jk93wq44kfh05s2w02aq'

const isSuccess = await sendToken({
    to: toAddress,
    symbol: 'Luna',
    value: '0.01', 
    network: 'mainnet'
 })

Custom Transactions

const postTransaction: (
  txOptions: CreateTxOptions,
  ramperNetwork: 'testnet' | 'mainnet',
  status?: WalletStatus,
  connectedWallet?: ConnectedWallet,
) => Promise<TxResult>

Error Handling

Use a try/catch block to detect if the user canceled the transaction or the transaction failed to be broadcasted successfully.

Last updated 1 year ago

Ramper SDK allows you to request a signed transaction from the user for subsequent broadcasting to the network. Ramper SDK is built around and but if you'd like to see Ramper SDK support other use cases, let us know on , or email us at team@ramper.xyz. In order to broadcast a transaction, you must first set up an Alchemy Provider.

Ramper Connect SDK supports custom Near transactions by supporting interactions with near-api-js. You can find an overview of near-api-js and their TypeDocs .

You can find a list of supported actions .

The result type is below. You can see more details about the FinalExecutionOutcome .

You can sign a transaction with signTransaction from the current logged in wallet. It is same as signer.signMessage of near-api-js. Look at the code .

You can sign a message with signMessage from the current logged in wallet. It is same as signer.signMessage of near-api-js. Look at the code .

Ramper Connect SDK supports all the custom transaction all the custom transactions that Terra Station supports with the post method. Provide the same txOption that is commonly used in Terra.js createAndSignTx method - more details can be found here: .

🔐
Ether.js
Alchemy
Discord
here
here
here
here
here
here
https://terra-money.github.io/terra.js/