Trying to Query Transactions

I’m trying to get a transaction through moralis, I expected an object but got something strange, why does the response from the query is an object with “className”? I’m using moralis/node and not react so I didn’t expect that, also the properties on the object are not accessible, for example calling “transaction.from_address” is undefined and have only 4 keys, but when using JSON.stringify it shows the whole object as expected…

Why is that? and what is the right way to parse this?

This is the object I get:|

ParseObject {
  id: 'qdZ8jFbDD2kIBCjajh02KUzK',
  _localId: undefined,
  _objCount: 0,
  className: 'EthTransactions'

But then when I do JSON.stringify it has more fields…

somehow you can print that object contents with JSON.stringify

you can try ['from_address'] or .get syntax

thanks for sharing this information

1 Like

calling transaction.from_address is undefined… I get the raw Parse object, I’m guessing you parse it it POJO for some queries. but for others you don’t.

For now the only way to get the underlying POJO/JSON is to convert the object to json which calls “toJSON” and that gives me the actual POJO, but that option is weird.

So I already know you guys work with parse, and this is the object I get:

But wouldn’t it be nicer to convert it to a normal object?
Also based on the type definition it should return a proper object based on the generic type, which it doesn’t.

yes, we are using parse server, I would expect it to work somehow to get those attributes without the need to do that json conversion

can you paste some code that replicates it?

1 Like

You should be able to just run this script with node, providing valid credentials.

import Moralis from "moralis/node";

const main = async () => {
  await Moralis.start({
    serverUrl: process.env.MORALIS_SERVER_URL,
    appId: process.env.MORALIS_APP_ID

  const [myTransaction] = await new Moralis.Query("EthTransactions").find();

  if (!myTransaction) {
    throw new Error("you have no transactions");

  // this is the issue I have
  if (myTransaction.from_address === undefined) {
    throw new Error(
      "Transaction is a parse object, when it should be a plain old javascript object (POJO)"

  console.log("yay, you solved it!");


1 Like