Etherscan API 有哪些替代品?

Etherscan API 可以被一些替代方案替代,它們?nèi)缦拢?/p>

如何開始使用 Etherscan API?

要開始使用 Etherscan API,您需要在 Etherscan 上創(chuàng)建一個帳戶并獲取 API 密鑰。要創(chuàng)建帳戶,請轉到此鏈接并點擊屏幕右上角的“登錄”按鈕。

之后,點擊登錄框下方的藍色“注冊”按鈕。要注冊新賬戶,您需要提供電子郵件地址并創(chuàng)建唯一的用戶名和密碼。

完成后,點擊藍色的“創(chuàng)建帳戶”按鈕。之后,轉到您提供的電子郵件地址并打開確認電子郵件。確認后,登錄您新創(chuàng)建的帳戶。

登錄后,導航到“API-KEY”下拉菜單,然后單擊藍色的“+添加”按鈕來創(chuàng)建一個新的API密鑰,如下圖所示:

命名您的 API 密鑰,然后您就可以開始使用和探索它了,這將在以下文章標題中展示。

如何使用 Etherscan API 獲取單個地址的以太幣余額?

要使用 Etherscan API 獲取單個地址的以太幣余額,您需要使用提供的地址和 API 密鑰向帳戶模塊和余額操作端點發(fā)出請求。

為此,我們將使用 Python 請求庫,并且為了增加趣味性,我們將使用可在網(wǎng)上找到的已知鯨魚地址:

requests.get('https://api.etherscan.io/api?module=account&action=balance&address=0x4976a4a02f38326660d17bf34b431dc6e2eb2327&tag=latest&apikey=A1C15S3AXQHQ7PVVDX63VVK2IBAECS448Z').json()
{'status': '1', 'message': 'OK', 'result':'29724721687169089009293'}

如何使用 Etherscan API 按地址獲取正常交易列表?

要使用 Etherscan API 獲取正常交易列表,您需要向帳戶模塊和 txlist 操作端點發(fā)送請求,每次調用將返回最多 10k 條記錄。

此端點將與 pandas 庫一起使用來創(chuàng)建數(shù)據(jù)框。由于端點有點混亂,我將以更清晰的方式展示它們,調用它們的方式與我們之前的示例相同。

https://api.etherscan.io/api
?module=account
&action=txlist
&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a
&startblock=0
&endblock=99999999
&page=1
&offset=10
&sort=asc
&apikey=YourApiKeyToken

這將存儲在數(shù)據(jù)變量內(nèi)部,我們將響應轉換為 pandas 數(shù)據(jù)框并以轉置的方式打印出最后 5 個點以查看所有返回參數(shù)。

data = pd.DataFrame(data['result'])
data.tail().T

如何使用 Etherscan API 通過地址獲取 ERC20 代幣轉移事件列表?

要使用 Etherscan API 按地址獲取 ERC20 代幣轉移事件列表,您需要向帳戶模塊和 tokentx 操作端點發(fā)送請求。此端點需要合約的地址和地址端點。

https://api.etherscan.io/api
?module=account
&action=tokentx
&contractaddress=0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2
&address=0x4e83362442b8d1bec281594cea3050c8eb01311c
&page=1
&offset=100
&startblock=0
&endblock=27025780
&sort=asc
&apikey=YourApiKeyToken

我們將響應放入數(shù)據(jù)框中,就像我們在前面的例子中所做的那樣。

如何使用 Etherscan API 獲取合約?

當合約模塊和 getabi 操作端點被請求時,Etherscan API 可以獲取合約數(shù)據(jù)。此端點還需要 API 密鑰和地址參數(shù)。

https://api.etherscan.io/api
?module=contract
&action=getabi
&address=0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413
&apikey=YourApiKeyToken

如何使用 Etherscan API 檢查交易狀態(tài)?

要使用 Etherscan API 檢查交易狀態(tài),用戶需要向交易模塊和gettxreceiptstatus操作發(fā)出請求。交易哈希碼也需要作為參數(shù)發(fā)送。

https://api.etherscan.io/api
?module=transaction
&action=gettxreceiptstatus
&txhash=0x513c1ba0bebf66436b5fed86ab668452b7805593c05073eb2d51d3a52f480a76
&apikey=YourApiKeyToken
{'status': '1', 'message': 'OK', 'result': {'status': '1'}}

如何使用Etherscan API獲取區(qū)塊數(shù)據(jù)?

要使用 Etherscan API 獲取塊數(shù)據(jù),您需要getblockreward使用提供的塊號作為請求參數(shù)來訪問塊模塊和操作端點。

https://api.etherscan.io/api
?module=block
&action=getblockreward
&blockno=2165403
&apikey=YourApiKeyToken

如何使用 Etherscan API 獲取日志?

要使用 Etherscan API 獲取日志,您需要向日志模塊和getLogs操作端點發(fā)出 API 請求。所需的參數(shù)是發(fā)件人/收件人區(qū)塊、地址、主題和 API 密鑰。以下是示例請求:

https://api.etherscan.io/api
?module=logs
&action=getLogs
&fromBlock=379224
&toBlock=latest
&address=0x33990122638b9132ca29c723bdf037f1a891a70c
&topic0=0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545
&apikey=YourApiKeyToken

如何將 Geth/Parity 代理與 Etherscan API 一起使用?

要使用帶有 Etherscan API 的 Geth/Parity 代理,您需要訪問代理模塊端點。此模塊下有多個端點,例如eth_blockNumber、、等等eth_getBlockByNumbereth_call

例如,我們將獲取eth_getStorageAt從指定地址的存儲位置返回值的端點:

https://api.etherscan.io/api
?module=proxy
&action=eth_getStorageAt
&address=0x6e03d9cce9d60f3e9f2597e13cd4c54c55330cfd
&position=0x0
&tag=latest
&apikey=YourApiKeyToken
{'jsonrpc': '2.0',
'id': 1,
'result': '0x0000000000000000000000003d0768da09ce77d25e2d998e6a7b6ed4b9116c2d'}

如何使用 Etherscan API 獲取代幣數(shù)據(jù)?

要使用 Etherscan API 獲取代幣數(shù)據(jù),您將可以訪問多個端點,這些端點可以返回 ERC20 代幣供應、賬戶余額、歷史數(shù)據(jù)等內(nèi)容。

為了獲得代幣供應,我們執(zhí)行以下操作:

https://api.etherscan.io/api
?module=stats
&action=tokensupply
&contractaddress=0x57d90b64a1a57749b0f932f1a3395792e12e7055
&apikey=YourApiKeyToken
{'status': '1', 'message': 'OK', 'result': '21265524714464'}

如何使用 Etherscan API 進行 gas 追蹤?

要將 gas 跟蹤器與 Etherscan API 結合使用,您必須查看可用 gas 端點列表。Etherscan API 提供的端點包括 gas 估算、gas 預言機、每日 gas 限額、總 gas 使用量、gas 價格等。

例如,讓我們獲得氣體確認時間的估計:

https://api.etherscan.io/api
?module=gastracker
&action=gasestimate
&gasprice=2000000000
&apikey=YourApiKeyToken
{'status': '1', 'message': 'OK', 'result': '3615'}

如何使用 Etherscan API 獲取統(tǒng)計數(shù)據(jù)?

Etherscan API 可以獲得各種統(tǒng)計數(shù)據(jù),例如以太幣的總供應量、最新價格、節(jié)點總數(shù)、節(jié)點大小、平均網(wǎng)絡哈希率、歷史市值、交易數(shù)量、新地址數(shù)量、交易費用等。

例如,我們來看看 Ether 2.0 的總供應量:

https://api.etherscan.io/api
?module=stats
&action=ethsupply2
&apikey=YourApiKeyToken
{'status': '1',
'message': 'OK',
'result': {'EthSupply': '118194367499000000000000000',
'Eth2Staking': '309618220365297000000000',
'BurntFees': '738514872810670998934509'}}

上一篇:

OpenSea API – 基本指南

下一篇:

Bittrex API – 入門指南
#你可能也喜歡這些API文章!

我們有何不同?

API服務商零注冊

多API并行試用

數(shù)據(jù)驅動選型,提升決策效率

查看全部API→
??

熱門場景實測,選對API

#AI文本生成大模型API

對比大模型API的內(nèi)容創(chuàng)意新穎性、情感共鳴力、商業(yè)轉化潛力

25個渠道
一鍵對比試用API 限時免費

#AI深度推理大模型API

對比大模型API的邏輯推理準確性、分析深度、可視化建議合理性

10個渠道
一鍵對比試用API 限時免費