合约地址交易列表 - Etherscan API

时间:2021-05-21 13:34:50

标签: blockchain ethereum etherscan

有谁知道如何从合约地址获取交易列表 我已经尝试过 etherscan.io API https://etherscan.io/apis#contracts

我已按照说明接收包含合约地址的所有交易列表的响应: 使用以下网址 = https://api.etherscan.io/api?module=account&action=txlist&address=&startblock=0&endblock=99999999&sort=asc&apikey=

下面,我对 Etherscan API 的 http 请求 =

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);
  };
};

而且,我收到状态为 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
  • “未找到交易”
  • 结果 = []

这很奇怪,虽然我的合约在访问 goerli etherscan 时有交易可见。合约部署在Goerli tesnet上。

我需要 Etherscan API 方面的帮助,除非有不同的方法来获取测试网上已部署合约的完整交易列表。我用 web3.eth ...

找不到任何东西

感谢您的帮助

1 个答案:

答案 0 :(得分:1)

Goerli Etherscan 有不同的 API 主机。

您需要使用 https://api-goerli.etherscan.io/ 而不是 https://api.etherscan.io/

来源:https://goerli.etherscan.io/apis#accounts