First I set the variable tokenArray:
const tokenArray = [
'<token contract address 1>',
'<token contract address 2>',
'<token contract address 3>',
etc...
]
I have this function:
async getTokens() {
const ownerAddr = this.account;
const balances = await this.web3.alchemy.getTokenBalances(ownerAddr, tokenArray, process.env.BLOCK_NUMBER)
return balances
And I run it like this:
getTokens().then(function (result) {
console.log(result);
The function will then return all of my current token balances but not my token balances as of the specified block height, followed by this error.
/Users/<myusername>/Desktop/Dev/token-balance-through-time/node_modules/@alch/alchemy-web3/dist/cjs/util/promises.js:28
callback(null, result);
^
TypeError: callback is not a function
at /Users/<myusername>/Desktop/Dev/token-balance-through-time/node_modules/@alch/alchemy-web3/dist/cjs/util/promises.js:28:9
at processTicksAndRejections (node:internal/process/task_queues:96:5)
<myusername>@<mycomputername> token-balance-through-time %
How do I call getTokenBalances at a particular block height? BTW getTokenBalances is from @alch/alchemy-web3 and imported at the top of the file like this. const { createAlchemyWeb3 } = require('@alch/alchemy-web3');