I’m building a tool that I’ll be sharing (free & open source) with the community.
I can view an account’s node rewards and other ANT transactions in a browser with a URL like: https://arbiscan.io/token/0xa78d8321b20c4ef90ecd72f2588aa985a4bdb684?a=0x12a6af697db2af05796f6c139df1714c7cdeb765.
I can make an Etherscan API call with a URL like: https://api.etherscan.io/v2/api?chainid=42161&module=account&action=tokentx&address=0x12a6af697db2af05796f6c139df1714c7cdeb765&contractaddress=0xa78d8321b20c4ef90ecd72f2588aa985a4bdb684&startblock=0&endblock=99999999&page=1&offset=10&sort=asc&apikey=…
blockNumber “…”
timeStamp “…”
hash “…”
nonce “620”
blockHash “…”
from “…”
contractAddress “0xa78d8321b20c4ef90ecd72f2588aa985a4bdb684”
to “0x12a6af697db2af05796f6c139df1714c7cdeb765”
value “…”
tokenName “Autonomi”
tokenSymbol “ANT”
tokenDecimal “18”
transactionIndex “30”
gas “…”
gasPrice “…”
gasUsed “…”
cumulativeGasUsed “…”
input “deprecated”
confirmations “…”
But nowhere in the output is the value for the “Method” field shown. (“Pay For Quotes”, “Batch Airdrop”, etc) Am I making an API call to the wrong endpoint?
1 Like
Ok so it seems that I need to use the tx hash in a follow-up API call ala: https://api.etherscan.io/v2/api?chainid=42161&module=proxy&action=eth_getTransactionByHash&txhash=0x22cbf588b2aeae8040e5c17fd0c12bdfa4966ea081dfa092a6393ae595eabcaa&apikey=…
to retrieve tx details, then within that use an ABI decoder on the input field to finally be able to access the method field. ‘Cool’.
1 Like
So I’ve written the code to do a series of API calls.
- Using the Autonomi contract address I get the contract’s ABI.
- Using an account address I get a list of ‘ERC20 - Token Transfer Events’. That list includes all transaction data for the two transactions seen at Autonomi (ANT) Token Tracker | Arbitrum One, except for “Method”, such as “Pay for Quotes.”
- Using transaction hash from a transaction I make an eth_getTransactionByHash API call to extract the input.
- Using the contract ABI and transaction hash input I decode the input.
- Using the selector I search the ABI’s functions to find a match.
Unfortunately it ends with not finding a matching function. Do I have that flow correct?
Really all I’m trying to do is get a list of Pay For Quotes for an address and it’s unbelievably convoluted. I must be doing something wrong. Does anyone know? @dirvine please? (slightly desperate)
Once I figure this out it’s all down hill with what I’m building.
1 Like