@@ -5,19 +5,22 @@ var web3 = new Web3();
5
5
var router = express . Router ( ) ;
6
6
7
7
web3 . setProvider ( new web3 . providers . HttpProvider ( process . env . ENODE_BASE || 'http://localhost:8545' ) ) ;
8
- var coinbase = web3 . eth . coinbase ;
9
8
10
9
/**
11
10
* GET ethereum coinbase
12
11
*/
13
12
router . get ( '/coinbase' , function ( req , res , next ) {
14
- res . json ( { 'data' :{ 'coinbase' : coinbase } } ) ;
13
+ res . json ( { 'data' :{ 'coinbase' : web3 . eth . coinbase } } ) ;
15
14
} ) ;
16
15
17
16
/**
18
17
* GET ethereum account balance
19
18
*/
20
19
router . get ( '/balance' , function ( req , res , next ) {
20
+ var coinbase = web3 . eth . coinbase ;
21
+ if ( req . query . address != null && req . query . address != '' && req . query . address != undefined ) {
22
+ coinbase = req . query . address ;
23
+ }
21
24
var balance = web3 . fromWei ( web3 . eth . getBalance ( coinbase ) , "ether" ) . toString ( 10 ) + ' ether' ;
22
25
res . json ( { 'data' :{ 'coinbase' : coinbase , 'balance' : balance } } ) ;
23
26
} ) ;
@@ -60,6 +63,18 @@ router.get('/transaction', function(req, res, next) {
60
63
res . json ( { 'data' :{ "txHash" : txHash } } ) ;
61
64
} ) ;
62
65
66
+ /**
67
+ * GET transactionReceipt
68
+ * https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethgettransactionreceipt
69
+ */
70
+ router . get ( '/transactionReceipt' , function ( req , res , next ) {
71
+ var transactionHash = req . query . transactionHash ;
72
+ if ( transactionHash == null || transactionHash == '' || transactionHash == undefined ) {
73
+ res . json ( { 'error' : { 'code' : 102 , 'message' : 'transactionHash is null' } } ) ;
74
+ }
75
+ res . json ( { 'data' : web3 . eth . getTransactionReceipt ( transactionHash ) } ) ;
76
+ } ) ;
77
+
63
78
/**
64
79
* GET estimate gas
65
80
* https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethestimategas
0 commit comments