Cloud function querying Archive node filtered by block

After setting up with (replaced some with placeholders):

const web3Archive = Moralis.web3ByChain("0x1");
const archiveContract = new web3Archive.eth.Contract(abi, "0x...");

I can run:

const archiveSomethingRes = await archiveContract.methods["getSomething()"]().call();

And it returns the latest something from that view function no problem.

However, when adding a block filter it just ignores the filter and returns the latest anyway. The four syntax attempts I’ve tried within the .call() portion:

  1. .call({ block_number: 14000000 })
  2. .call({ blockNumber: 14000000 })
  3. .call({ block_identifier: 14000000 })
  4. .call({ from_block: 14000000, to_block: 14000000 })

All to no avail. How can I filter to a specific block?


you can try this syntax:

web3 = new Moralis.Web3(new Moralis.Web3.providers.HttpProvider("<id>/bsc/mainnet"));

not sure if it will help you

Using your suggested syntax to instantiate an archive web3 instance, I tried all four of the above block filters within the .call() but again they returned only the latest block. It seems that both are valid web3 instances, but neither of them are correctly filtering by block.

Any other suggestions?

how can you do it without a cloud function?