@@ -252,7 +252,7 @@ export default {
252
252
// Dial node
253
253
dialNode () {
254
254
// Get provider
255
- web3 .setProvider (new web3.providers.HttpProvider ( this .nodeUrl ) )
255
+ web3 .setProvider (this .nodeUrl )
256
256
},
257
257
// Get balance
258
258
getBalance (address ) {
@@ -261,12 +261,12 @@ export default {
261
261
this .dialNode ()
262
262
263
263
// Get balance
264
- let vm = this
264
+ let self = this
265
265
web3 .eth .getBalance (address)
266
266
.then (function (balance ){
267
267
console .log (' Get balance: ' + balance)
268
268
balance = Units .convert (balance, ' wei' , ' eth' )
269
- vm .balance = balance + ' Ether'
269
+ self .balance = balance + ' Ether'
270
270
})
271
271
} else {
272
272
console .log (' Address not valid' )
@@ -316,26 +316,26 @@ export default {
316
316
var payload = contractDeploy .encodeABI ();
317
317
318
318
// Save current this
319
- let vm = this
320
- vm .deploying = true
321
- vm .contractAddress = ' '
319
+ let self = this
320
+ self .deploying = true
321
+ self .contractAddress = ' '
322
322
323
323
// Estimate gas price
324
324
web3 .eth .getGasPrice (function (gasPriceError , result ) {
325
325
if (gasPriceError) {
326
326
console .log (' Get GasPrice error: ' , gasPriceError)
327
- vm .deploying = false
327
+ self .deploying = false
328
328
return
329
329
} else {
330
330
var gasPrice = result;
331
331
console .log (' Get GasPrice success: ' , gasPrice)
332
332
var gasPriceHex = web3 .utils .numberToHex (gasPrice)
333
333
334
334
// Get nonce
335
- web3 .eth .getTransactionCount (vm .address , function (nonceError , nonce ) {
335
+ web3 .eth .getTransactionCount (self .address , function (nonceError , nonce ) {
336
336
if (nonceError) {
337
337
console .log (" Nonce error : " , nonceError)
338
- vm .deploying = false
338
+ self .deploying = false
339
339
return
340
340
}
341
341
else {
@@ -352,7 +352,7 @@ export default {
352
352
gasPrice: gasPriceHex,
353
353
gasLimit: gasLimitHex,
354
354
value: ' 0x00' ,
355
- from: vm .address ,
355
+ from: self .address ,
356
356
data: payload
357
357
}
358
358
console .log (" Raw Transaction: " ,rawTx)
@@ -368,16 +368,16 @@ export default {
368
368
web3 .eth .sendSignedTransaction (' 0x' + serializedTx .toString (' hex' ))
369
369
.on (' error' , function (error ){
370
370
console .log (' sendRawTransaction error : ' , error)
371
- vm .deploying = false
371
+ self .deploying = false
372
372
})
373
373
.on (' transactionHash' , function (transactionHash ){
374
374
console .log (' sendRawTransaction success : ' , transactionHash)
375
- vm .deployTransactionHash = transactionHash
375
+ self .deployTransactionHash = transactionHash
376
376
})
377
377
.on (' receipt' , function (receipt ){
378
378
console .log (receipt .contractAddress )
379
- vm .contractAddress = receipt .contractAddress
380
- vm .deploying = false
379
+ self .contractAddress = receipt .contractAddress
380
+ self .deploying = false
381
381
})
382
382
.on (' confirmation' , function (confirmationNumber , receipt ){
383
383
console .log (confirmationNumber)
@@ -411,25 +411,25 @@ export default {
411
411
console .log (' Contract: ' , contract);
412
412
413
413
// Save current this
414
- let vm = this
415
- vm .executing = true
414
+ let self = this
415
+ self .executing = true
416
416
417
417
// Estimate gas price
418
418
web3 .eth .getGasPrice (function (gasPriceError , result ) {
419
419
if (gasPriceError) {
420
420
console .log (' Get GasPrice error: ' , gasPriceError)
421
- vm .executing = false
421
+ self .executing = false
422
422
return
423
423
} else {
424
424
var gasPrice = result;
425
425
console .log (' Get GasPrice success: ' , gasPrice)
426
426
var gasPriceHex = web3 .utils .numberToHex (gasPrice)
427
427
428
428
// Get nonce
429
- web3 .eth .getTransactionCount (vm .address , function (nonceError , nonce ) {
429
+ web3 .eth .getTransactionCount (self .address , function (nonceError , nonce ) {
430
430
if (nonceError) {
431
431
console .log (" Nonce error : " , nonceError)
432
- vm .executing = false
432
+ self .executing = false
433
433
return
434
434
}
435
435
else {
@@ -438,7 +438,7 @@ export default {
438
438
console .log (" Nonce hex : " , nonce)
439
439
440
440
// Execute the smart contract method
441
- var newValue = parseInt (vm .storageValue )
441
+ var newValue = parseInt (self .storageValue )
442
442
var contractCallData = contract .methods .set (newValue)
443
443
console .log (' contractCallData : ' , contractCallData)
444
444
@@ -454,8 +454,8 @@ export default {
454
454
gasPrice: gasPriceHex,
455
455
gasLimit: gasLimitHex,
456
456
value: ' 0x00' ,
457
- from: vm .address ,
458
- to: vm .contractAddress ,
457
+ from: self .address ,
458
+ to: self .contractAddress ,
459
459
data: payload
460
460
}
461
461
console .log (" Raw Transaction: " ,rawTx)
@@ -471,15 +471,15 @@ export default {
471
471
web3 .eth .sendSignedTransaction (' 0x' + serializedTx .toString (' hex' ))
472
472
.on (' error' , function (error ){
473
473
console .log (' sendRawTransaction error : ' , error)
474
- vm .executing = false
474
+ self .executing = false
475
475
})
476
476
.on (' transactionHash' , function (transactionHash ){
477
477
console .log (' sendRawTransaction success : ' , transactionHash)
478
- vm .execTransactionHash = transactionHash
478
+ self .execTransactionHash = transactionHash
479
479
})
480
480
.on (' receipt' , function (receipt ){
481
481
console .log (receipt)
482
- vm .executing = false
482
+ self .executing = false
483
483
})
484
484
.on (' confirmation' , function (confirmationNumber , receipt ){
485
485
console .log (confirmationNumber)
@@ -504,11 +504,11 @@ export default {
504
504
// Exec contract
505
505
var contract = new web3.eth.Contract (abi, this .contractAddress )
506
506
console .log (' start call get' )
507
- let vm = this ;
507
+ let self = this ;
508
508
contract .methods .get ().call ().then (
509
509
function (result ) {
510
510
console .log (' Result: ' + result)
511
- vm .retreivedValue = result
511
+ self .retreivedValue = result
512
512
})
513
513
}
514
514
}
0 commit comments