Get Started on Terra

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 Connect SDK also provides WalletView 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 https://example.ramper.xyz/

Install Ramper Connect 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.

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')
}
More information on constructing custom transactions can be found here: https://terra-money.github.io/terra.js/

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!
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 Introduction for ways to reach us).