Error when getting a simple transaction from Moralis JS SDK

Hello, I have been having problems using the method Moralis.Web3API.native.getTransaction for about 1 month now.
When calling the function (eventually) Iโ€™m getting an internal Moralis error like this:

Cannot read property 'page_size' of undefined

These are the parameters I am using:

{
	"chainId": 137,
	"dstAddress": "0x020dd38e5c3553c167bd0dfa29180b58c0ccffe9",
	"rpcUrl": "https://polygon-rpc.com",
	"srcAddress": "0x81ab6Fd4A68d0aDDFAD65F9F97Bc1427dCd40C8E",
	"transaction_hash": "0xdbdae7fc45746bf28e89a064c29c3f30043f32671c8af2d7120dc1c9b46c0551"
}

This is the error stack trace:

TypeError: Cannot read property 'page_size' of undefined
    at Function.getNextOptions (/workspace/node_modules/moralis/lib/node/MoralisWeb3Api.js:122:17)
    at Function.fetchFromServer (/workspace/node_modules/moralis/lib/node/MoralisWeb3Api.js:249:32)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async MoralisService.verify (/workspace/dist/src/provider/service/moralis.service.js:35:29)

Seemed youโ€™re not using a valid param. You can check here in the docs regarding the proper parameters https://docs.moralis.io/moralis-dapp/web3-api/native#gettransaction-new

As mentioned you need to use valid parameters. This works:

const options = {
      chain: 'polygon',
      dstAddress: '0x020dd38e5c3553c167bd0dfa29180b58c0ccffe9',
      rpcUrl: 'https://polygon-rpc.com',
      srcAddress: '0x81ab6Fd4A68d0aDDFAD65F9F97Bc1427dCd40C8E',
      transaction_hash:
        '0xdbdae7fc45746bf28e89a064c29c3f30043f32671c8af2d7120dc1c9b46c0551',
    };

The Cannot read property 'page_size' of undefined error happens when the tx hash isnโ€™t valid.

1 Like

Sorry, Iโ€™m already sending the parameter transaction_hash with underscore, I put it incorrectly here on the forum, do you have a ticket for this error with any forecast to fix it? For us it is detrimental that an error is throwed instead of being returned undefined.

You can catch it or use the workaround here where it should just be undefined.

1 Like