Moralis.Web3API.account.getTransactions() Broken

Moralis.Web3API.account.getTransactions() method is broken after removing support of “offset”,
const options = {
chain: chainKey,
address: address,
order: orderBy,
from_block: from_block,
//offset: 3,
cursor: cursor,
limit: limit
};
return await Moralis.Web3API.account.getTransactions(options);
“cursor” is not working also next is also not working as mention https://docs.moralis.io/moralis-dapp/web3-api#web3-api-pagination-examples-with-.next here.

this code works fine for me:

result = await Moralis.Web3API.account.getTransactions({ chain: 'bsc', address:'0x322FAa41ed28E189D8816f27d9eB5F003E3ff83F' })
console.log(result)
while (result.next){
    result = await result.next()
    console.log(result)
}

what doesn’t work in your case?

Could you please try with limit

let result = await Moralis.Web3API.account.getTransactions({ chain: 'bsc', address:'0x322FAa41ed28E189D8816f27d9eB5F003E3ff83F', limit: 2 })
console.log(result)
while (result.next){
    console.log("next")
    result = await result.next()
    console.log(result)
}

Output

{
  total: 3675,
  page: 0,
  page_size: 2,
  cursor: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZGRyZXNzIjoiMHgzMjJmYWE0MWVkMjhlMTg5ZDg4MTZmMjdkOWViNWYwMDNlM2ZmODNmIiwiY2hhaW4iOiJic2MiLCJ0b19ibG9jayI6IjE4MzQzNzAwIiwiYmxvY2tfb2Zmc2V0IjoxLCJ0b3RhbCI6MzY3NSwicGFnZSI6MSwibGltaXQiOjIsIm9mZnNldCI6MCwiaWF0IjoxNjU0MjcwOTU2fQ.TuK_0qdJPJQAK3vw162i2Ts6rztybZxMzlMmCjU3qXQ',
  result: [
    {
      hash: '0x026ccee651cedf237d98bc7f018fec480786c3f6a7b1109a1ab88a941b1d2be9',
      nonce: '3405',
      transaction_index: '59',
      from_address: '0x322faa41ed28e189d8816f27d9eb5f003e3ff83f',
      to_address: '0x85dfdbfa48afd39dc5c7459b9c908357f5230ce9',
      value: '3549670266986702',
      gas: '21000',
      gas_price: '5000000000',
      input: '0x',
      receipt_cumulative_gas_used: '9296277',
      receipt_gas_used: '21000',
      receipt_contract_address: null,
      receipt_root: null,
      receipt_status: '1',
      block_timestamp: '2022-06-02T17:15:49.000Z',
      block_number: '18343718',
      block_hash: '0x71fece6c110cdba084b6685129ab0c9beb77ce0c2073750ff0a6e19551597dd3',
      transfer_index: [Array]
    },
    {
      hash: '0xb3c8dc69f5100557ea5525420df11497add6a8efb058b8459185a77c372fa32d',
      nonce: '3404',
      transaction_index: '4',
      from_address: '0x322faa41ed28e189d8816f27d9eb5f003e3ff83f',
      to_address: '0xaec271a66feb3d47bdab54dc38c36231657b007b',
      value: '0',
      gas: '190809',
      gas_price: '10000000000',
      input: '0x12aa4f7400000000000000000000000000000000000000000000000000000000000022c20000000000000000000000000000000000000000000000000000000000025bf800000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000d2f14e04d441000',
      receipt_cumulative_gas_used: '222247',
      receipt_gas_used: '105352',
      receipt_contract_address: null,
      receipt_root: null,
      receipt_status: '1',
      block_timestamp: '2022-06-02T17:14:55.000Z',
      block_number: '18343700',
      block_hash: '0x56ee06de004e65c126ca49e46a8255471738f3f8a9f0754bd617991ff0eea0c8',
      transfer_index: [Array]
    }
  ]
}

no next page.

1 Like

it seems to be a problem, we will investigate, thanks for reporting

it works better now, at least for that limit 2

Still it not rendering next page :frowning:

What it does? Same as before?

this works for me:

result = await Moralis.Web3API.account.getTransactions({ chain: 'bsc', address:'0x322FAa41ed28E189D8816f27d9eB5F003E3ff83F', limit: 2})
  console.log("page 0 " + JSON.stringify(result.result))
  result = await result.next()
  console.log("page 1 " + JSON.stringify(result.result))

now I am getting error
core

let result = await Moralis.Web3API.account.getTransactions({ chain: 'bsc', address:'0x322FAa41ed28E189D8816f27d9eB5F003E3ff83F', limit: 2})
  console.log("page 0 " + JSON.stringify(result.result))
  result = await result.next()
  console.log("page 1 " + JSON.stringify(result.result))
  result = await result.next()
  console.log("page 2 " + JSON.stringify(result.result))

Error

[Nest] 7827  - 05/06/2022, 17:19:39   ERROR [ExceptionsHandler] result.next is not a function
TypeError: result.next is not a function

You use latest version of Moralis sdk?

Thanks for your help, its working without order: “asc” param. This api need some testing and also doc https://docs.moralis.io/moralis-dapp/web3-api/account is outdated.

1 Like