-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
93 lines (67 loc) · 2.46 KB
/
Copy pathapp.js
File metadata and controls
93 lines (67 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
var express=require("express");
var app=express();
var bodyParser =require("body-parser");
var amount;
app.set("view engine","ejs");
var ethers = require('ethers');
const Web3 =require("web3");
// const walletAddress = "0x8690F1feff62008A396B31c2C3f380bD0Ca6d8b8";
//var balance = web3.eth.getBalance(walletAddress); //Will give value in.
// console.log("balance");
// console.log(balance);
// const a = async()=>{
// const bal = await web3.eth.getBalance(walletAddress);
// console.log(bal);
// };
// console.log(web3.currentProvider);
var bip39 = require('bip39')
var mnemonic = bip39.generateMnemonic();
var SHA256 = require("crypto-js/sha256");
console.log(SHA256(bip39.mnemonicToSeedHex('basket actual')));
function broadCastTransHash(prvKey){
const web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/3a10d3e387f348f4bfa43e0eb0ac2737"));
console.log(web3.version);
broadCast();
};
var privateKey = '0x600c10b4758b26fa25419c4f4ccec0c1e071a9ab3a7122488bbf3f545354afe5';
var wallet = new ethers.Wallet(privateKey);
wallet.provider = ethers.providers.getDefaultProvider('rinkeby');
// var transaction = {
// gasLimit: 1000000,
// to: "0x31b98d14007bdee637298086988a0bbd31184523",
// data: "0x",
// value: ethers.utils.parseEther("0.1"),
// };
// Estimate the gas cost for the transaction
//var estimateGasPromise = wallet.estimateGas(transaction);
//estimateGasPromise.then(function(gasEstimate) {
// console.log(gasEstimate);
//});
// Send the transaction*******
//var sendTransactionPromise = wallet.sendTransaction(transaction);
// sendTransactionPromise.then(function(transactionHash) {
// console.log(transactionHash);
// });
app.get("/",function(req,res){
res.send("Hi there!,welcome to the landing page!");
});
app.get("/:amount",function(req,res){
amount =req.params.amount;
res.send("Your amount entered is :" +amount);
var transaction = {
gasLimit: 1000000,
to: "0x31b98d14007bdee637298086988a0bbd31184523",
data: "0x",
value: ethers.utils.parseEther(amount.toString()),
};
var sendTransactionPromise = wallet.sendTransaction(transaction);
sendTransactionPromise.then(function(transactionHash) {
console.log(transactionHash);
});
console.log("Success!");
});
app.use(bodyParser.urlencoded({extended:true}));
function broadCast(){};
app.listen(process.env.PORT,process.env.IP,function(){
console.log("The app.js Server Has Started!");
});