-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
132 lines (124 loc) · 3.56 KB
/
index.html
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Bank App</title>
<link
href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh"
crossorigin="anonymous"
/>
<link rel="stylesheet" href="/BlockchainApp/main.css" />
<link
href="https://fonts.googleapis.com/css?family=Raleway&display=swap"
rel="stylesheet"
/>
</head>
<body>
<!-- navbar -->
<!-- perform functions -->
<div class="container " id="mc">
<div class="row">
<div class="col-lg-6"><h1>Blockchain Based Banking App</h1></div>
<div class="col-lg-6">
<div class="container" id="f">
<div class="container" id="o">
<input id="amount" type="text" placeholder="Enter Amount" />
<h4 id="balance"></h4>
<button class="btn btn-dark" id="deposit">Deposit</button>
<button class="btn btn-dark" id="withdraw">Withdraw</button>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/gh/ethereum/web3.js@1.0.0-beta.34/dist/web3.min.js"></script>
<script
src="https://code.jquery.com/jquery-3.4.1.slim.js"
integrity="sha256-BTlTdQO9/fascB1drekrDVkaKd9PkwBymMlHOiG+qLI="
crossorigin="anonymous"
></script>
<script>
var contract;
$(document).ready(function() {
web3 = new Web3(web3.currentProvider);
var address = "0x8B15C0875e7ceED1D2715Cc134Ea26CeDFfC5942";
var abi = [
{
constant: false,
inputs: [
{
name: "amt",
type: "int256"
}
],
name: "Deposit",
outputs: [],
payable: false,
stateMutability: "nonpayable",
type: "function"
},
{
constant: false,
inputs: [
{
name: "amt",
type: "int256"
}
],
name: "Withdraw",
outputs: [],
payable: false,
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [],
payable: false,
stateMutability: "nonpayable",
type: "constructor"
},
{
constant: true,
inputs: [],
name: "getBalance",
outputs: [
{
name: "",
type: "int256"
}
],
payable: false,
stateMutability: "view",
type: "function"
}
];
contract = new web3.eth.Contract(abi, address);
contract.methods
.getBalance()
.call()
.then(function(bal) {
$("#balance").html("Balance: ₹ " + bal);
});
});
$("#deposit").click(function() {
var amt = 0;
amt = parseInt($("#amount").val());
web3.eth
.getAccounts()
.then(function(accounts) {
var acc = accounts[0];
return contract.methods.Deposit(amt).send({ from: acc });
})
.then(function(tx) {
console.log(tx);
})
.catch(function(tx) {
console.log(tx);
});
});
</script>
</body>
</html>