Last active
July 28, 2019 18:30
-
-
Save totiz/fab8cfbe60aa9e3aad50a46ee2e1b2f6 to your computer and use it in GitHub Desktop.
Libra Wallet Minting
This file contains 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 { LibraWallet, LibraClient, LibraNetwork } = require('kulap-libra') | |
const BigNumber = require('bignumber.js') | |
async function createWallet() { | |
// Generate an account | |
const wallet = new LibraWallet() | |
const account = wallet.newAccount() | |
return { | |
address: account.getAddress().toHex(), | |
mnemonic: wallet.config.mnemonic | |
} | |
} | |
async function mint(address, amount) { | |
const client = new LibraClient({ network: LibraNetwork.Testnet }); | |
const data = await client.mintWithFaucetService(address, BigNumber(amount).times(1e6)); | |
return data | |
} | |
(async () => { | |
// Create a wallet | |
const wallet = await createWallet() | |
console.log('wallet', wallet) | |
// Mint 1,000 libra coins | |
const mintingResult = await mint(wallet.address, 1000) | |
console.log('mintingResult', mintingResult) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment