Updated to the new etherscan API URL scheme.

Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
tarekskr 2018-02-15 08:51:28 -05:00 committed by Julien Eluard
parent 65a2f440c6
commit 6098da936a
No known key found for this signature in database
GPG Key ID: 6FD7DB5437FCBEF6
2 changed files with 5 additions and 5 deletions

View File

@ -7,9 +7,9 @@
(defn get-network-subdomain [network] (defn get-network-subdomain [network]
(case network (case network
("testnet" "testnet_rpc") "ropsten" ("testnet" "testnet_rpc") "api-ropsten"
("mainnet" "mainnet_rpc") "api" ("mainnet" "mainnet_rpc") "api"
("rinkeby" "rinkeby_rpc") "rinkeby")) ("rinkeby" "rinkeby_rpc") "api-rinkeby"))
(defn get-transaction-details-url [network hash] (defn get-transaction-details-url [network hash]
(let [network-subdomain (get-network-subdomain network)] (let [network-subdomain (get-network-subdomain network)]

View File

@ -5,17 +5,17 @@ from tests import info
def get_transactions(address: str) -> dict: def get_transactions(address: str) -> dict:
url = 'http://ropsten.etherscan.io/api?module=account&action=txlist&address=0x%s&sort=desc' % address url = 'http://api-ropsten.etherscan.io/api?module=account&action=txlist&address=0x%s&sort=desc' % address
return requests.request('GET', url=url).json()['result'] return requests.request('GET', url=url).json()['result']
def is_transaction_successful(transaction_hash: str) -> int: def is_transaction_successful(transaction_hash: str) -> int:
url = "https://ropsten.etherscan.io/api?module=transaction&action=getstatus&txhash=%s" % transaction_hash url = "https://api-ropsten.etherscan.io/api?module=transaction&action=getstatus&txhash=%s" % transaction_hash
return not int(requests.request('GET', url=url).json()['result']['isError']) return not int(requests.request('GET', url=url).json()['result']['isError'])
def get_balance(address): def get_balance(address):
url = 'http://ropsten.etherscan.io/api?module=account&action=balance&address=0x%s&tag=latest' % address url = 'http://api-ropsten.etherscan.io/api?module=account&action=balance&address=0x%s&tag=latest' % address
for i in range(5): for i in range(5):
try: try:
return int(requests.request('GET', url).json()["result"]) return int(requests.request('GET', url).json()["result"])