1

I have deployed a version of the open-zeppelin-subgraph (https://github.com/OpenZeppelin/openzeppelin-subgraphs) and I am tracking ERC20, ERC721 and ERC1155 tokens.

I am using this query:

    {
        account(id: "${walletAddress}") {
            ERC20balances {
                id
                value
            }
            ERC721tokens {
                id
                identifier
            }
            ERC1155balances {
                token {
                    id
                    identifier
                }
                valueExact
            }
        }
    }

The problem I have is that instead of getting empty arrays for wallets that does not have a balance of the tokens I am tracking, I am getting this:

{
  "data": {
    "account": null
  }
}

Why is this happening only for some addresses? I think this is the format I should get no matter what addresses I use:

{
  "data": {
    "account": {
      "ERC20balances": [],
      "ERC721tokens": [],
      "ERC1155balances": []
    }
  }
}
2
  • It happens when the subgraph is not fully synced. Could it be the case? Commented Mar 27, 2023 at 6:06
  • In this case I have checked that the subgraph is fully synced with the blockchain. Commented Mar 27, 2023 at 6:40

1 Answer 1

0

open-zeppelin-subgraph uses this function every time an account takes part in a transaction or event you are tracking in your subgraph:

export function fetchAccount(address: Address): Account {
    let account = new Account(address)
    account.save()
    return account
}

By "taking part" I mean being a sender or a receiver of a token or being a proposer or a voter. This will vary depending on the type of contracts you are tracking.

So, if the account you are looking for has never taken part in any transaction or event of the ones you are indexing, that account will appear as null because it has never been saved to the database as an account entity.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.