Hello! Im trying to get historical BSC transactions after logging in through MM and getting an empty array back.
I successfully log in and get my user name from Moralis
I also see all my BSC transactions in the Moralis dashboard…any ideas what Im doing wrong here?
const { authenticate, isAuthenticated, user, Moralis, logout, isInitialized } = useMoralis();
console.log(isInitialized); // returns true
const displayUserName = () => {
if (!isAuthenticated) return '';
console.log(Moralis.User.transactions); // returns undefined
console.log(Moralis.User.current);
return user.get('username');
};
const getUserTransactions = async (user: any) => {
// create query
const query = new Moralis.Query('BscTransactions');
query.equalTo('from_address', user.get('bscAddress'));
// run query
const results = await query.find();
console.log('user transactions:', results); // returning []
};
const getStats = () => {
const user = Moralis.User.current();
if (user) {
getUserTransactions(user).then((resp) => console.log(resp)); // undefined
}
};