How can I use trace_filter
with Moralis? I tried it the following:
const { ethers } = require('ethers')
const provider = new ethers.providers.getDefaultProvider('https://speedy-nodes-nyc.moralis.io/{token}/bsc/mainnet', { name: 'bc', chainId: 56 })
main()
async function main () {
const currentBlockNumber = await provider.getBlockNumber()
const fromBlockNumber = currentBlockNumber - 200
const toBlockNumber = currentBlockNumber
const result = await provider.send('trace_filter', [{
fromBlock: '0x' + fromBlockNumber.toString(16),
toBlock: '0x' + toBlockNumber.toString(16), // comment this line to change error
fromAddress: [],
toAddress: ['0xCe8F1eF93BACA83B21Fd6f6e1A3c75B3BD7Ba522'],
after: 0,
count: 20
}])
console.log(result)
}
βthe method trace_filter does not exist/is not availableβ
Error: processing response error (body="{\"jsonrpc\":\"2.0\",\"id\":42,\"error\":{\"code\":-32601,\"message\":\"the method trace_filter does not exist/is not available\"}}\n", error={"code":-32601}, requestBody="{\"method\":\"trace_filter\",\"params\":[{\"toAddress\":[\"0xCe8F1eF93BACA83B21Fd6f6e1A3c75B3BD7Ba522\"]}],\"id\":42,\"jsonrpc\":\"2.0\"}", requestMethod="POST", url="https://speedy-nodes-nyc.moralis.io/{token}/bsc/mainnet", code=SERVER_ERROR, version=web/5.5.1)
For example, commenting the line with toBlock
would result in:
βfromBlock must be less than or equal to toBlockβ
Error: bad response (status=401, headers={"date":"Sat, 19 Mar 2022 16:45:45 GMT","content-type":"text/plain","content-length":"47","connection":"close","cf-cache-status":"DYNAMIC","expect-ct":"max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"","server":"cloudflare","cf-ray":"6ee7ae299ed26b0c-GRU"}, body="fromBlock must be less than or equal to toBlock", requestBody="{\"method\":\"trace_filter\",\"params\":[{\"fromBlock\":\"0xf731c8\",\"fromAddress\":[],\"toAddress\":[\"0xCe8F1eF93BACA83B21Fd6f6e1A3c75B3BD7Ba522\"],\"after\":0,\"count\":20}],\"id\":45,\"jsonrpc\":\"2.0\"}", requestMethod="POST", url="https://speedy-nodes-nyc.moralis.io/{token}/bsc/mainnet", code=SERVER_ERROR, version=web/5.5.1)
Itβs documented in the rate limits:
https://docs.moralis.io/misc/rate-limit#speedy-node-requests
Btw, I didnβt receive the Discord invite using https://moralis.io/mage