contract's address transactions list - Etherscan API

5.5k Views Asked by At

Does anyone know how to obtain the list of transactions from a contract' address I have tried the etherscan.io API https://etherscan.io/apis#contracts

I have followed the instructions to receive a response with a list of all transaction for a contract's address : with the following url = https://api.etherscan.io/api?module=account&action=txlist&address=<CONTRACT_ADDRESS>&startblock=0&endblock=99999999&sort=asc&apikey=

Below, my http request to the Etherscan API =

export const fetchTransactions = () => {
  return (dispatch, _, { TaskCounter: { _address } }) => {
    const MYAPIKEY = "XXXXX";
    dispatch(fetchTransactionsPending());
    axios
      .get(
        `https://api.etherscan.io/api?module=account&action=txlist&address=${_address}&startblock=0&endblock=99999999&sort=asc&apikey=${MYAPIKEY}`
      )
      .then(console.dir)
      .catch(console.error);
  };
};

And, I get this response with status 200:

config: {url: "https://api.etherscan.io/api?module=account&action…ort=asc&apikey=13QNDPDD3AU1FY7K9V96S628AAPPRZK5T1", method: "get", headers: {…}, transformRequest: Array(1), transformResponse: Array(1), …}
data: {status: "0", message: "No transactions found", result: Array(0)}
headers: {cache-control: "private", content-length: "172", content-type: "application/json; charset=utf-8"}
request: XMLHttpRequest {readyState: 4, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, onreadystatechange: ƒ, …}
status: 200
  • "No transactions found"
  • result = []

This is very strange, although my contract has transactions visible when I visit the goerli etherscan. The contract is deployed on the Goerli tesnet.

I need assistance with the Etherscan API unless there is a different method to fetch the complete list of transactions for a deployed contract on a testnet. I could not find anything with web3.eth ...

thanks for the help

1

There are 1 best solutions below

0
On BEST ANSWER

Goerli Etherscan has a different API host.

You need to use https://api-goerli.etherscan.io/ instead of https://api.etherscan.io/

Source: https://goerli.etherscan.io/apis#accounts