[SOLVED] TypeError: Cannot read properties of undefined (reading 'token')

Seeing this error and not sure why, using the exact syntax found on the get wallet token transfers instructions for Node JS: https://docs.moralis.io/reference/getwallettokentransfers

Full code below (specific variables like API key and wallet replaced with all caps placeholders):

const Moralis = require("moralis/node");
const EvmChain = require("@moralisweb3/evm-utils");

const serverUrl = "MYSERVERURL";
const appId = "MYAPPID";

async function apiPull() {

    await Moralis.start({
        serverUrl,
        appId,
        apiKey: 'MYAPIKEY',
        logLevel: 'verbose'
    });

    console.log("started");

    let address = 'MYTESTWALLET';
    const chain = EvmChain.ETHEREUM;

    const response = await Moralis.EvmApi.token.getWalletTokenTransfers({
        address,
        chain,
    });

    console.log(response.result);
}

apiPull();

it could be this part that is undefined, before that token

maybe you have an older version of Moralis SDK

Yup that was the issue thanks! Had to update Moralis SDK with β€œnpm i moralis@latest react-moralis@latest”

1 Like