@@ -479,6 +479,238 @@ class CryptoAPIs {
479
479
480
480
return this . deleteRequest ( '/bc/btc/' + network + '/hooks/' + webhookID ) ;
481
481
}
482
+
483
+ getEthereumInfo ( network ) {
484
+
485
+ return this . getRequest ( '/bc/eth/' + network + '/info' ) ;
486
+ }
487
+
488
+ getEthereumBlock ( network , block ) {
489
+
490
+ return this . getRequest ( '/bc/eth/' + network + '/blocks/' + block ) ;
491
+ }
492
+
493
+ getEthereumLatestBlock ( network ) {
494
+
495
+ return this . getRequest ( '/bc/eth/' + network + '/blocks/latest' ) ;
496
+ }
497
+
498
+ getEthereumAddressBalance ( network , address ) {
499
+
500
+ return this . getRequest ( '/bc/eth/' + network + '/address/' + address + '/balance' ) ;
501
+ }
502
+
503
+ getEthereumAddressInfo ( network , address ) {
504
+
505
+ return this . getRequest ( '/bc/eth/' + network + '/address/' + address ) ;
506
+ }
507
+
508
+ getEthereumAddressTransactions ( network , address , index = 0 , limit = 50 ) {
509
+
510
+ return this . getRequest ( '/bc/eth/' + network + '/address/' + address + '/transactions?index=' + index + '&limit=' + limit ) ;
511
+ }
512
+
513
+ generateEthereumAddress ( network ) {
514
+
515
+ return this . postRequest ( '/bc/eth/' + network + '/address' , { } ) ;
516
+ }
517
+
518
+ generateEthereumAccount ( network , password ) {
519
+
520
+ return this . postRequest ( '/bc/eth/' + network + '/account' , {
521
+ password : password
522
+ } ) ;
523
+ }
524
+
525
+ getEthereumTransaction ( network , txHash ) {
526
+
527
+ return this . getRequest ( '/bc/eth/' + network + '/txs/hash/' + txHash ) ;
528
+ }
529
+
530
+ getEthereumTransactionsByBlock ( network , block , index = 0 , limit = 50 ) {
531
+
532
+ return this . getRequest ( '/bc/eth/' + network + '/txs/block/' + block + '?index=' + index + '&limit=' + limit ) ;
533
+ }
534
+
535
+ getEthereumTransactionByIndexInBlock ( network , block , index ) {
536
+
537
+ return this . getRequest ( '/bc/eth/' + network + '/txs/block/' + block + '/' + index ) ;
538
+ }
539
+
540
+ createEthereumTransaction ( network , from , to , gasPrice , gasLimit , value , password ) {
541
+
542
+ return this . postRequest ( '/bc/eth/' + network + '/txs/new' , {
543
+ fromAddress : from ,
544
+ toAddress : to ,
545
+ gasPrice : gasPrice ,
546
+ gasLimit : gasLimit ,
547
+ value : value ,
548
+ password : password
549
+ } ) ;
550
+ }
551
+
552
+ createEthereumTransactionWithPrivateKey ( network , from , to , gasPrice , gasLimit , value , privateKey ) {
553
+
554
+ return this . postRequest ( '/bc/eth/' + network + '/txs/new-pvtkey' , {
555
+ fromAddress : from ,
556
+ toAddress : to ,
557
+ gasPrice : gasPrice ,
558
+ gasLimit : gasLimit ,
559
+ value : value ,
560
+ privateKey : privateKey
561
+ } ) ;
562
+ }
563
+
564
+ sendEthereumTransaction ( network , from , to , value ) {
565
+
566
+ return this . postRequest ( '/bc/eth/' + network + '/txs/send' , {
567
+ fromAddress : from ,
568
+ toAddress : to ,
569
+ value : value
570
+ } ) ;
571
+ }
572
+
573
+ pushEthereumTransaction ( network , signedTx ) {
574
+
575
+ return this . postRequest ( '/bc/eth/' + network + '/txs/push' , {
576
+ signed_tx : signedTx
577
+ } ) ;
578
+ }
579
+
580
+ estimateEthereumTransactionGas ( network , from , to , value , data = null ) {
581
+
582
+ var body = {
583
+ fromAddress : from ,
584
+ toAddress : to ,
585
+ value : value
586
+ } ;
587
+
588
+ if ( data ) {
589
+ body [ 'data' ] = data ;
590
+ }
591
+
592
+ return this . postRequest ( '/bc/eth/' + network + '/txs/gas' , body ) ;
593
+ }
594
+
595
+ estimateEthereumSmartContractGas ( network ) {
596
+
597
+ return this . getRequest ( '/bc/eth/' + network + '/contracts/gas' ) ;
598
+ }
599
+
600
+ deployEthereumSmartContract ( network , privateKey , from , gasPrice , gasLimit , byteCode ) {
601
+
602
+ return this . postRequest ( '/bc/eth/' + network + '/contracts' , {
603
+ privateKey : privateKey ,
604
+ fromAddress : from ,
605
+ gasPrice : gasPrice ,
606
+ gasLimit : gasLimit ,
607
+ byteCode : byteCode
608
+ } ) ;
609
+ }
610
+
611
+ getEthereumAddressTokenBalance ( network , address , contract ) {
612
+
613
+ return this . getRequest ( '/bc/eth/' + network + '/tokens/' + address + '/' + contract + '/balance' ) ;
614
+ }
615
+
616
+ ethereumTransferTokens ( network , fromAddress , toAddress , contract , gasPrice , gasLimit , token , password = null , privateKey = null ) {
617
+
618
+ var body = {
619
+ fromAddress : fromAddress ,
620
+ toAddress : toAddress ,
621
+ contract : contract ,
622
+ gasPrice : gasPrice ,
623
+ gasLimit : gasLimit ,
624
+ token : token
625
+ } ;
626
+
627
+ if ( password ) {
628
+
629
+ body [ 'password' ] = password ;
630
+ } else {
631
+ body [ 'privateKey' ] = privateKey ;
632
+ }
633
+
634
+ return this . postRequest ( '/bc/eth/' + network + '/tokens/transfer' , body ) ;
635
+ }
636
+
637
+ ethereumCreatePayment ( network , fromAddress , toAddress , callbackURL , password = null , privateKey = null ) {
638
+
639
+ var body = {
640
+ fromAddress : fromAddress ,
641
+ toAddress : toAddress ,
642
+ callBack : callbackURL
643
+ } ;
644
+
645
+ if ( password ) {
646
+
647
+ body [ 'password' ] = password ;
648
+ } else {
649
+ body [ 'privateKey' ] = privateKey ;
650
+ }
651
+
652
+ return this . postRequest ( '/bc/eth/' + network + '/payments' , body ) ;
653
+ }
654
+
655
+ ethereumDeletePayment ( network , uuid ) {
656
+
657
+ return this . deleteRequest ( '/bc/eth/' + network + '/payments/' + uuid ) ;
658
+ }
659
+
660
+ ethereumListPayment ( network ) {
661
+
662
+ return this . getRequest ( '/bc/eth/' + network + '/payments' ) ;
663
+ }
664
+
665
+ ethereumListPaymentHistory ( network ) {
666
+
667
+ return this . getRequest ( '/bc/eth/' + network + '/payments/history' ) ;
668
+ }
669
+
670
+ ethereumCreateUnconfirmedTransactionWebHook ( network , callbackURL ) {
671
+
672
+ return this . postRequest ( '/bc/eth/' + network + '/hooks' , {
673
+ event : 'UNCONFIRMED_TX' ,
674
+ url : callbackURL
675
+ } ) ;
676
+ }
677
+
678
+ ethereumCreateConfirmedTransactionWebHook ( network , callbackURL , transaction , confirmations ) {
679
+
680
+ return this . postRequest ( '/bc/eth/' + network + '/hooks' , {
681
+ event : 'CONFIRMED_TX' ,
682
+ url : callbackURL ,
683
+ confirmations : confirmations ,
684
+ transaction : transaction
685
+ } ) ;
686
+ }
687
+
688
+ ethereumCreateNewBlockWebHook ( network , callbackURL ) {
689
+
690
+ return this . postRequest ( '/bc/eth/' + network + '/hooks' , {
691
+ event : 'NEW_BLOCK' ,
692
+ url : callbackURL
693
+ } ) ;
694
+ }
695
+
696
+ ethereumCreateAddressTransactionWebHook ( network , callbackURL , address ) {
697
+
698
+ return this . postRequest ( '/bc/eth/' + network + '/hooks' , {
699
+ event : 'ADDRESS' ,
700
+ address : address ,
701
+ url : callbackURL
702
+ } ) ;
703
+ }
704
+
705
+ ethereumListAllWebHooks ( network ) {
706
+
707
+ return this . getRequest ( '/bc/eth/' + network + '/hooks' ) ;
708
+ }
709
+
710
+ ethereumDeleteWebHook ( network , webhookID ) {
711
+
712
+ return this . deleteRequest ( '/bc/eth/' + network + '/hooks/' + webhookID ) ;
713
+ }
482
714
}
483
715
484
716
module . exports = CryptoAPIs ;
0 commit comments