Web3 getTransaction返回null

时间:2019-02-02 10:19:50

标签: web3 web3js ether

我遇到web3.eth.getTransaction的问题。

在本地区块链上使用此功能时,给定我刚刚进行的交易哈希,该功能将返回一个适当的对象。但是,当我尝试对主网使用相同的设置时,getTransaction始终返回null。

  1. 我可以将哈希传递给getTransaction并在etherscan上找到tx,而函数返回null。
  2. 在本地区块链上一切正常,主网始终返回null
  3. 我正在使用网络版本:“ ^ 1.0.0-beta.37”
  4. 我还将web3库用于代码中的不同内容,并且它们在主网和本地均有效。因此,只有getTransaction表现得很奇怪。

我的功能如何:

const advancedValidation = async hash => {
    const tx = await web3Proxy.web3.eth.getTransaction(hash);
    console.log(tx) // Will always be null
    if (!tx) return null;
    ...
}

1 个答案:

答案 0 :(得分:0)

因此,如果您给定的交易哈希不在Mainnet链中,则当前函数将返回null。当然,如果您已连接到以太坊链,请再通过Etherescan检查提供的哈希值。