0

I created a geth Ethereum private chain and successfully committed the transaction through web3.js and saw the corresponding transaction in the specified block, but my web3.eth.getPastLogs() method always returns an empty array.

I query the specified log with the following code, get an empty array.

var options = {
  fromBlock: 0,
  toBlock: 164
};
const logs = await web3.eth.getPastLogs(options);
console.log(logs);

But there is actually a transaction on this block:

> web3.eth.getBlockByNumber(164)
{
  baseFeePerGas: "0x7",
  difficulty: "0x20000",
  extraData: "0xd683010a0c846765746886676f312e3230856c696e7578",
  gasLimit: "0x38413a",
  gasUsed: "0x5208",
  hash: "0xf0c7d98c9b667ad70b594405d594d264595a00b6d7b648b06cd09657b4ff6e37",
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",  miner: "0x14a77685d92e6af6cfa1789452c78b3555072ccf",
  mixHash: "0x5254ea4527bf4e8a4ba6f10b9c3d3fb65dc11dc681705c51ab895cda93ea6135",
  nonce: "0x478a31f90245dd02",
  number: "0xa4",
  parentHash: "0x928ea4930bb54e9448aeb03849dd2adbfbe5a4ffdf1b507a4f8face780768c60",
  receiptsRoot: "0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2",
  sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
  size: "0x28a",
  stateRoot: "0x8ca274f2d0c4d10de9fa44bda54020951fe348477aefb3060aa84a0470afa9a3",
  timestamp: "0x643666ac",
  totalDifficulty: "0x14ddc2a",
  transactions: ["0xe4f79279ffad0f3cd0cd58cb90c02d399f70b316f848480bbf8097e036bc47e4"],
  transactionsRoot: "0x5ffe10e63547dec9514d6e6bdf7d1a5984d56f610ab79d67bb4ae9c2f2400210",
  uncles: []
}

Here is the version of my geth and the startup command information:

Version: 1.10.12-stable
geth --datadir data/folder --networkid 1541 --http --http.api "eth,net,web3" --http.addr "0.0.0.0" --http.port "8545" --http.corsdomain "*" --syncmode full --nodiscover console

I've been looking for a long time but I can't find the problem. Can anyone help me...

I tried this command on the goerli test net as expected.

TylerH
  • 20,799
  • 66
  • 75
  • 101
ATFWUS
  • 9
  • 3
  • 1
    It's possible that your geth node is not indexing the logs. By default, geth nodes are configured to only index a certain range of blocks for events and logs. You can try increasing the --gcmode flag when starting geth to index more blocks. For example, you can try using --gcmode archive to index all blocks. – marsh-wiggle Apr 12 '23 at 10:07
  • Thank you for your suggestion. I tried to add this flag, but unfortunately the above problem still exists. @marsh-wiggle – ATFWUS Apr 12 '23 at 10:29

0 Answers0