Skip to content

Commit d981818

Browse files
committed
testnet input added
1 parent e5a4d8b commit d981818

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/init.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,24 @@ var restify = require('restify');
33
const querystring = require('querystring');
44

55
const url = 'https://api.etherscan.io/api';
6+
const testUrl = 'testnet.etherscan.io';
7+
68

79
/**
810
* @module etherscan/api
911
*/
10-
module.exports = function (apiKey) {
12+
13+
// chain is for testnet
14+
module.exports = function (apiKey, chain) {
1115

1216
if (!apiKey) {
1317
apiKey = 'YourApiKeyToken';
1418
}
1519

1620
var client = restify.createJsonClient({
17-
url: url,
21+
// added testnet condition
22+
url: chain === 'testnet' ? testUrl : url,
23+
// url: url,
1824
version: '*'
1925
});
2026

0 commit comments

Comments
 (0)