0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

QuickNode で ethreum アーカイブノードにアクセスするメモ($9/month で 10 回/月まで)

Posted at

Python web3 で Uniswap の流動性ペアの残高を取得するメモ(最新ブロックのみ)
https://qiita.com/syoyo/items/d4db214903bd0105247c

過去ブロックの残高見たいようです.

$9/month プランで 10 回/month までクエリできました(Free Archive Call = 128 ブロック前のデータにアクセス).

Matic など L2 ノード(ただこちらは過去履歴にはアクセスできないっぽい), BSC なども対応しています.

2021/03/21 時点で, 128 blocks 以上前の 2021/01/05 の Uniswap WETH/USDT 残高にアクセスしてみます.

import json

from web3 import Web3,HTTPProvider

web3 = Web3(HTTPProvider('https://cold-solitary-resonance.quiknode.pro/xxxx/'))
blockNumber=web3.eth.blockNumber
print(blockNumber)


addr_weth_usdt = '0x0d4a11d5EEaaC28EC3F61d100daF4d40471f1852' # Uniswap WETH/USDT pair

abi_weth_usdt = json.loads(open('abi.json').read())
contract = web3.eth.contract(address=addr_weth_usdt, abi=abi_weth_usdt)
print("decimals", contract.functions.decimals().call())
print("totalSupply", contract.functions.totalSupply().call())
print("token0 addr", contract.functions.token0().call())
print("token1 addr", contract.functions.token1().call())

block_no=11592051  # Jan-05-2021 03:29:53 AM +UTC
print("reserves(token0, token1, blocktime): ", contract.functions.getReserves().call(block_identifier=block_no))
456195507074386999986802
12081912
decimals 18
totalSupply 2258295820883597461
token0 addr 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
token1 addr 0xdAC17F958D2ee523a2206206994597C13D831ec7
reserves(token0, token1, blocktime):  [81586037830394576150231, 85811089218896, 1609817339]

Voila!

課題

Scale プラン($299 / month)でも, アーカイブノードへのアクセスは 300 / month までです.

$250/month の archive node アドオン契約すれば各プランでのコール最大($9 プランだと 300k /month)で呼べるようですが... ちょっとお高いですよね.

税金計算のためにスポットで使うにはいいかもですが(チェックしたいのが少なければ etherscan で手動取得でもいいかもですが), 常時アーカイブノードにアクセスしたいのであれば自前で建てたほうが安上がりかもしれません.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?