Skip to content

Commit

Permalink
start updating transfer example
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Constantine Moore committed Jan 26, 2022
1 parent f6bea97 commit cbad080
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions example/transfer.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
const Env = require('./static/env').env;
const kavaUtils = require('../src/utils').utils;
const KavaClient = require('../src/client').KavaClient;

import { utils } from '../src/utils';
import { env } from './static/env';
import { KavaClient } from '../src/client';
const KAVA_CONVERSION_FACTOR = 10 ** 6;

var main = async () => {
const recipient = 'kava1g0qywkx6mt5jmvefv6hs7c7h333qas5ks63a6t';

// Start new Kava client
kavaClient = new KavaClient(Env.KavaEndpoints.Testnet);
kavaClient.setWallet(Env.KavaAccount.Testnet.Mnemonic);
const kavaClient = new KavaClient(env.KavaEndpoints.Testnet);
kavaClient.setWallet(env.KavaAccount.Testnet.Mnemonic);
kavaClient.setBroadcastMode('async');
await kavaClient.initChain();

// First let's check our account balances
let balances = await kavaClient.getBalances(Env.KavaAccount.Testnet.Address);
let balances = await kavaClient.getBalances(env.KavaAccount.Testnet.Address);
console.log('Balances:', balances);
// Print our KAVA balance (if we have one)
let kavaBalance = balances.find(
let kavaBalance = balances?.find(
(item) => item.denom.toUpperCase() === 'UKAVA'
);
if (kavaBalance) {
console.log(
'\tBalance (kava):',
kavaBalance.amount / KAVA_CONVERSION_FACTOR
Number(kavaBalance.amount) / KAVA_CONVERSION_FACTOR
);
}

// Transfer 1 kava to recipient's address
const coins = kavaUtils.formatCoins(1 * KAVA_CONVERSION_FACTOR, 'ukava');
const coins = utils.formatCoins(1 * KAVA_CONVERSION_FACTOR, 'ukava');
const txHash = await kavaClient.transfer(recipient, coins);
console.log('Tx hash:', txHash);

Expand Down

0 comments on commit cbad080

Please sign in to comment.