Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {
- Coin, LCDClient, MnemonicKey, MsgSwap
- } from '@terra-money/terra.js'
- import axios from 'axios'
- async function main() {
- const mk = new MnemonicKey({
- mnemonic: '',
- })
- let chainID = 'columbus-5'
- let gasPrices = await axios('https://columbus-fcd.terra.dev/v1/txs/gas_prices')
- gasPrices = gasPrices.data
- const lcd = new LCDClient({
- URL: 'https://lcd.terra.dev',
- chainID: 'columbus-5',
- gasAdjustment: 2,
- gasPrices,
- isClassic: true
- })
- const wallet = lcd.wallet(mk)
- try {
- const swap = new MsgSwap(
- wallet.key.accAddress,
- new Coin('usdr', '100000'),
- 'uusd'
- )
- const tx = await wallet.createAndSignTx({
- msgs: [swap],
- chainID,
- })
- await lcd.tx.broadcastSync(tx, chainID)
- } catch (e) {
- console.log(e)
- }
- }
- main().catch()
Advertisement
Add Comment
Please, Sign In to add comment