GoogleスプレッドシートからGASでEtherScanのAPIをたたいて、トランザクションの一覧を取得してみました。
EtherScanのユーザー登録+API key取得
まずは、EtherScanのサイトでアカウントを作成します。

Ethereum (ETH) Blockchain Explorer
Etherscan allows you to explore and search the Ethereum blockchain for transactions, addresses, tokens, prices and other activities taking place on Ethereum (ET...
アカウント作成が完了したら、API Keyを取得します。




スプレッドシートとGoogle Apps Scriptを作成
適当にスプレッドシートを作成し、ツール > スクリプトエディタでスクリプトを作成。
function getEtherTransaction() { // 定数設定 const sheet = SpreadsheetApp.getActiveSheet() const apiKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" // EtherScanで取得したAPI key const address = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" // ウォレットのアドレス // EtherScanからデータ取得 const response = UrlFetchApp.fetch(`https://api.etherscan.io/api?module=account&action=txlist&address=${address}&startblock=0&endblock=99999999&sort=asc&apikey=${apiKey}`) const json = JSON.parse(response) // シート貼り付け用の配列 const data = [] // key取得 data.push( Object.keys(json.result[0]) ) // value取得 for ( const item of json.result ){ data.push(Object.values(item) ) } // シートに貼り付け sheet.getRange(1,1,data.length,data[0].length).setValues(data) }
実行してみる
早速実行してみました。

意外と簡単にデータが取得できました。
が、timeStampとかvalueとか、諸々処理したほうが良さそうです。
コメント