This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const KAVA_DENOM = "ukava"; | |
const HARD_DENOM = "hard"; | |
const USDX_DENOM = "usdx"; | |
const BNB_DENOM = "bnb"; | |
var usdFormatter = new Intl.NumberFormat('en-US', { | |
style: 'currency', | |
currency: 'USD', | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const _ = require("lodash"); | |
const BnbApiClient = require("@binance-chain/javascript-sdk"); | |
const kava = require("@kava-labs/javascript-sdk"); | |
const bnbCrypto = BnbApiClient.crypto; | |
const KavaClient = kava.KavaClient; | |
const kavaUtils = kava.utils; | |
const BINANCE_CHAIN_API_TESTNET = "https://testnet-dex.binance.org"; | |
const BINANCE_CHAIN_DEPUTY = "tbnb1et8vmd0dgvswjnyaf73ez8ye0jehc8a7t7fljv"; | |
const bnbAddress = "your binance chain testnet address"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const otherSwapID = utils.calculateSwapID(randNumHash, senderOtherChain, sender); | |
console.log(otherSwapID) // 5589d6c1919871398ca0c2caa4f32f2a85a34efab33d61a3a4d56baabdd41be4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const kava = require("@kava-labs/javascript-sdk"); | |
const utils = kava.utils; | |
const randNumHash = "ababe8f6b36a206820ae75f868634129c9b63f715f0609024eb6e7a084aa70a8" | |
const sender = client.wallet.address // kava1sl8glhaa9f9tep0d9h8gdcfmwcatghtdrfcd2x | |
const senderOtherChain = "tbnb1et8vmd0dgvswjnyaf73ez8ye0jehc8a7t7fljv" | |
const kavaSwapID = utils.calculateSwapID(randNumHash, sender, senderOtherChain); | |
console.log(kavaSwapID) // 7f0f1f09ed603cb7da8852dc0f71e661256ac00e20f7afea80e43e12e64a67d9 | |
const otherSwapID = utils.calculateSwapID(randNumHash, senderOtherChain, sender); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const kava = require("@kava-labs/javascript-sdk"); | |
const utils = kava.utils; | |
const randomNumber = utils.generateRandomNumber(); | |
const timestamp = Math.floor(Date.now() / 1000); | |
const randomNumberHash = utils.calculateRandomNumberHash(randomNumber, timestamp); | |
// Example expected values | |
console.log(randomNumber) // a4f9b0ebf97a00cf6a711d7a999e4f7e5653c38d691e5cb1beec5f72263e12c9 | |
console.log(timestamp) // 1585782178 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: gpl-3.0 |