|
15 | 15 | } else { |
16 | 16 | createWeb3(); |
17 | 17 | } |
| 18 | + document.getElementById("setNet").addEventListener("click", setNetwork); |
| 19 | + document.getElementById("loginButton").addEventListener("click", Login); |
| 20 | + document.getElementById("completeFields").addEventListener("click", CompleteFields); |
| 21 | + document.getElementById("submitButton").addEventListener("click", SubmitToBlockchain); |
| 22 | + document.getElementById("checkButton").addEventListener("click", CheckIntegrity); |
| 23 | + |
18 | 24 |
|
19 | 25 | function SubmitToBlockchain (){ |
20 | 26 |
|
|
56 | 62 | var nonce = "0x" + (nonceValue).toString(16); |
57 | 63 | rawtx = { |
58 | 64 | nonce: nonce, |
59 | | - gasPrice: this.web3.utils.toHex(estimatedGas), |
60 | | - gasLimit: this.web3.utils.toHex(GasLimit), |
| 65 | + gasPrice: web3.utils.toHex(estimatedGas), |
| 66 | + gasLimit: web3.utils.toHex(GasLimit), |
61 | 67 | to: contractAddress, |
62 | 68 | data: bytecodeData |
63 | 69 | }; |
|
67 | 73 | tx.sign(privateKey); |
68 | 74 | var raw = "0x" + tx.serialize().toString("hex"); |
69 | 75 |
|
70 | | - this.web3.eth.sendSignedTransaction(raw) |
| 76 | + web3.eth.sendSignedTransaction(raw) |
71 | 77 | .once('transactionHash', function(hash){ |
72 | 78 | document.getElementById("comment").innerHTML = "Transaction sent, please wait til' it is mined" |
73 | 79 | //Arranco el spin y el boton |
|
217 | 223 | var nonce = "0x" + (nonceValue).toString(16); |
218 | 224 | rawtx = { |
219 | 225 | nonce: nonce, |
220 | | - gasPrice: this.web3.utils.toHex(estimatedGas), |
221 | | - gasLimit: this.web3.utils.toHex(GasLimit), |
| 226 | + gasPrice: web3.utils.toHex(estimatedGas), |
| 227 | + gasLimit: web3.utils.toHex(GasLimit), |
222 | 228 | to: contractAddress, |
223 | 229 | data: bytecodeData |
224 | 230 | }; |
|
227 | 233 |
|
228 | 234 | tx.sign(privateKey); |
229 | 235 | var raw = "0x" + tx.serialize().toString("hex"); |
230 | | - this.web3.eth.sendSignedTransaction(raw) |
| 236 | + web3.eth.sendSignedTransaction(raw) |
231 | 237 | .once('transactionHash', function(hash){ |
232 | 238 | document.getElementById("comment").innerHTML = "Transaction sent, please wait til' it is mined"; |
233 | 239 | //Arranco el spin y oculto el boton |
234 | 240 | document.getElementById("spin").style.display = "block"; |
235 | 241 | document.getElementById("loginButton").style.display = "none"; |
236 | 242 | }) |
237 | 243 | .on('error', function(error){ |
238 | | - //console.log(error); |
239 | 244 | document.getElementById("comment").innerHTML = ""; |
240 | 245 | document.getElementById("error").innerHTML = "Error in transaction"; |
241 | 246 | document.getElementById("spin").style.display = "none" |
|
370 | 375 | } |
371 | 376 |
|
372 | 377 | function createWeb3(){ |
373 | | - console.log("func createweb3"); |
374 | 378 | switch (selectedNetwork) { |
375 | 379 | case "Ropsten": |
376 | 380 | web3 = new Web3(); |
|
0 commit comments