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

Get Started on Terra

Last updated 1 year ago

Good to know: Currently, Ramper's Terra SDK only supports React. A stand-alone version is under consideration.

Overview

Ramper's Terra SDK provides an easy wallet solution for developers to integrate into their DApps. Once integrated, your users will be able to log in with a popular OAuth solution and instantly interact with a Terra wallet.

Ramper SDK also provides component, which provides the DApp with various wallet-related functionalities such as fiat-on-ramp, transaction history and token transfers.

In addition, Ramper's Terra SDK provides native support to connect your DApp with TerraStation and WalletConnect (more wallet supports coming soon) as well.

See these functions in action at

Install Ramper SDK

Setup Terra's wallet provider

Terra's Wallet-Provider SDK provides access to TerraStation and WalletConnect. Ramper's SDK interfaces with Terra's Wallet-Provider to support both native wallets.

Follow these steps before continuing:

Install SDK

$ yarn add @ramper/terra

or

$ npm i @ramper/terra

User signup & login

import { signIn } from '@ramper/terra'
import { useWallet } from '@terra/wallet-provider'

const walletToUse = useWallet()
const signInResult = await signIn(walletToUse)

Calling await signIn(walletToUse) will 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/terra'

const user = getUser()

Check balance

Once logged in, you can check the current coins and tokens balance:

import { getUserTokens } from '@ramper/terra'

await getUserTokens('testnet')

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/terra'

...

try {
  const toAddress = 'terra123aqd9edra72sehg84jk93wq44kfh05s2w02aq'
  const isSuccess = await sendToken({
    to: toAddress,
    symbol: 'Luna',
    value: '0.01', 
    network: 'mainnet'
  })
} catch (ex) {
  console.error('Transaction failed')
}

Send transaction

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

import { sendFromWallet } from '@ramper/terra'
import { useWallet } from '@terra/wallet-provider'
import { useConnectedWallet } from '@terra/wallet-provider'

const { status } = useWallet()
const connectedWallet = useConnectedWallet()
try {
  await sendFromWallet(toAddress, 'UST', 200, 'testnet', status, connectedWallet)
} catch (e) {
  console.error('Transaction failed')
}

Post Terra.js message transactions

Similar to terra.js CreateAndSignTx method and wallet-provider's post method, Ramper Connect SDK exposes a method called postTransaction to send custom transactions.

import { Coin, CreateTxOptions, Fee, MsgSwap } from '@terra-money/terra.js'
import { postTransaction } from '@ramper/terra'
import { useWallet } from '@terra/wallet-provider'
import { useConnectedWallet } from '@terra/wallet-provider'

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

const user = await getUser()

try {
  const res: TxResult = await postTransaction({
    msgs: [new MsgSwap(user.wallets['terra'].publicKey, new Coin('uusd', 1000000), 'ukrw')],
    memo: 'Swapping USD for KRW',
  }, 'testnet', status, connectedWallet)
} catch (ex) {
  console.error('Transaction failed')
}

Sign out

Users can log out or disconnect their wallet with:

import { signOut } from '@ramper/terra'
import { useWallet } from '@terra/wallet-provider'

const walletToUse = useWallet()
await signOut(walletToUse)

Yup, it really is just that easy!

More information on constructing custom transactions can be found here:

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 (see for ways to reach us).

🔐
WalletView
https://example.ramper.xyz/
https://github.com/terra-money/wallet-provider/tree/main/packages/src/@terra-money/wallet-provider
https://terra-money.github.io/terra.js/
Introduction