var etherize = require("etherize");
var request = require('request');
console.log('Fetching tenant and wallet tokens');
request.get({url: 'https://etherize-get-wallet-token-nlzkx43w905y.runkit.sh/'},
function (err, httpResponse, walletToken) {
if (err) {
console.log(err);
return;
}
var userPassword = "password";
var walletFactory = new etherize.WalletFactory();
walletFactory.makeTestWalletFromEtherize(userPassword, walletToken,
function walletHandler(wallet) {
console.log(wallet);
var balancePromise = wallet.getBalance();
balancePromise.then(function(balance) {
console.log('Wallet balance: ' + etherize.Ethers.utils.formatEther(balance) + ' ETH');
var bobsAddress = '0x3D7967C25C8816571B70E929006ea270cc461ed5';
var amount = etherize.Ethers.utils.parseEther('0.1');
console.log('Sending 0.1 ETH to Bob');
var promiseSend = wallet.send(bobsAddress, amount);
promiseSend.then(function(transaction) {
console.log(transaction);
});
});
});
});