-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.html
More file actions
216 lines (191 loc) · 9.73 KB
/
Copy pathindex.html
File metadata and controls
216 lines (191 loc) · 9.73 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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<!DOCTYPE html>
<html>
<head>
<title>Welcome to Vue</title>
<script src="https://unpkg.com/vue"></script>
</head>
<body>
<div id="app">
<h1>{{ greeting }}</h1>
</div>
<div id="button-1">
address:
<input v-model="address" placeholder="address">
<p>balance is: {{ balance }}</p>
<button v-on:click="submitButton">submit</button>
</div>
<pre>
<div id="sendEth">
<h3>Send Ether</h3>
To Address:
<input v-model="address" placeholder="address">
nonce:
<input v-model="nonce" placeholder="nonce">
data:
<input v-model="data" placeholder="data">
gas Price:
<input v-model="gasPrice" placeholder="gasPrice">
gas Limit:
<input v-model="gasLimit" placeholder="gasLimit">
value:
<input v-model="value" placeholder="value">
<p>txn id: {{ txnId }}</p>
<button v-on:click="send">SEND</button>
</div>
</pre>
<pre>
<div id="contract">
<h3>Contract call</h3>
Contract Address:
<input v-model="contractAddress" placeholder="contractAddress">
Contract Abi:
<input v-model="abi" placeholder="abi">
arg1:
<input v-model="arg1" placeholder="arg1">
arg1:
<input v-model="arg2" placeholder="arg2">
gas Price:
<input v-model="gasPrice" placeholder="gasPrice">
gas Limit:
<input v-model="gasLimit" placeholder="gasLimit">
value:
<input v-model="value" placeholder="value">
<p>txn id / Result : {{ txnId }}</p>
<button v-on:click="send">CALL</button>
DEF balance:
<input v-model="DEFbalance" placeholder="balance">
<button v-on:click="balance">GET BALANCE</button>
</div>
</pre>
<!-- <script src="https://cdn.rawgit.com/ethereum/web3.js/v0.20.6/dist/web3.min.js"></script> -->
<script src="https://cdn.rawgit.com/ethereum/web3.js/v1.0.0-beta.35/dist/web3.min.js"></script>
<script>
var web3 = new Web3(new Web3.providers.HttpProvider("https://rinkeby.infura.io"));
// let util = require('ethereumjs-util');
// let tx = require('ethereumjs-tx');
var app = new Vue({
el: '#app',
data: {
greeting: 'My Ethereum Wallet',
}
})
var button1 = new Vue({
el: '#button-1',
data: {
address: '',
balance: '',
},
methods: {
submitButton: function (event) {
web3.eth.getBalance(button1.address, 'latest', (err, res) => {
if (err) {
console.log('error ' + err);
} else {
button1.balance=res;
}
});
}
}
})
var sendEth = new Vue({
el: '#sendEth',
data: {
address: '',
nonce: '',
data: '',
gasPrice: '20000000000',
gasLimit: '21000',
txnId: '',
value: '',
},
methods: {
send: function (event) {
const privateKey = 'EB5513D506854DC8452B62312A6FAD27EE0D62C3FDCD0129FC2B4C7E008ED154';
const account = web3.eth.accounts.privateKeyToAccount('0x' + privateKey);
web3.eth.accounts.wallet.add(account);
web3.eth.defaultAccount = account.address;
let address = account.address;
console.log("address: " + address);
console.log(web3.eth.accounts.wallet);
console.log("accounts: " + web3.eth.accounts);
let transactionCount = web3.eth.getTransactionCount(address);
//eth
let txObj = {
from: address,
to: sendEth.address,
value: sendEth.value,
gas: sendEth.gasLimit,
gasPrice: sendEth.gasPrice,
data: sendEth.data,
};
console.log(txObj);
web3.eth.sendTransaction(txObj, (err, transactionHash) => {
if (err) {
console.log('error ' + err);
} else {
sendEth.txnId = transactionHash;
console.log(sendEth.txnId);
}
});
}
}
})
var contract = new Vue({
el: '#contract',
data: {
contractAddress: '0x907B98479a589abAFC72926837B726B0D3582C3F',
abi: '[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"uint256"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_subtractedValue","type":"uint256"}],"name":"decreaseApproval","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_addedValue","type":"uint256"}],"name":"increaseApproval","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":false,"stateMutability":"nonpayable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"burner","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"}]',
arg1: '0xea9568670a5fE44D42e76386d208165c25A320f7',
arg2: '10',
gasPrice: '20000000000',
gasLimit: '21000',
txnId: '',
value: '0',
DEFbalance: '',
},
methods: {
send: function (event) {
const privateKey = 'EB5513D506854DC8452B62312A6FAD27EE0D62C3FDCD0129FC2B4C7E008ED154';
const account = web3.eth.accounts.privateKeyToAccount('0x' + privateKey);
web3.eth.accounts.wallet.add(account);
web3.eth.defaultAccount = account.address;
let address = account.address;
console.log("address: " + address);
console.log(web3.eth.accounts.wallet);
console.log("accounts: " + web3.eth.accounts);
var contractObj = new web3.eth.Contract(JSON.parse(contract.abi, contract.contractAddress));
contractObj.options.address = contract.contractAddress;
contractObj.options.from = address; // default from address
contractObj.options.gasPrice = '20000000000'; // default gas price in wei
contractObj.options.gas = 210000; // provide as fallback always 5M gas
console.log(contractObj.options.address);
contractObj.methods.transfer(contract.arg1, contract.arg2).send({from: address}).on('transactionHash', function(hash){
contract.txnId = hash;
console.log(hash);
}).on('error', console.error);
},
balance: function (event) {
const privateKey = 'EB5513D506854DC8452B62312A6FAD27EE0D62C3FDCD0129FC2B4C7E008ED154';
const account = web3.eth.accounts.privateKeyToAccount('0x' + privateKey);
web3.eth.accounts.wallet.add(account);
web3.eth.defaultAccount = account.address;
let address = account.address;
console.log("address: " + address);
console.log(web3.eth.accounts.wallet);
console.log("accounts: " + web3.eth.accounts);
var contractObj = new web3.eth.Contract(JSON.parse(contract.abi, contract.contractAddress));
contractObj.options.address = contract.contractAddress;
contractObj.options.from = address; // default from address
contractObj.options.gasPrice = '20000000000'; // default gas price in wei
contractObj.options.gas = 210000; // provide as fallback always 5M gas
console.log(contractObj.options.address);
contractObj.methods.balanceOf(address).call({from: address}).then(function(result){
console.log(result);
contract.DEFbalance = result;
});
}
}
})
</script>
</body>
</html>