Ok, so how’s this work? getTokenTransfers() is obviously not a
convienience function.
import { useEffect, useState } from "react";
import { useMoralis } from "react-moralis";
const emptyList = [];
export const useTokenShifts = (props) => {
const { isAuthenticated, Moralis } = useMoralis();
const [Txs, setTxs] = useState(emptyList);
const [isLoading, setIsLoading] = useState(true);
console.groupCollapsed("useTransactions");
console.log("Loaded isAuthenticated: ", isAuthenticated);
console.log("Received token name: ");
useEffect(() => {
if (isAuthenticated) {
console.debug("Calling getTransactions...");
Moralis.Web3.getTokenTransfers({ usePost: true }).then((userTrans) => {
console.debug("All ERC20 transaction data: ", userTrans);
setTxs(userTrans);
setIsLoading(false);
});
} else {
setTxs(emptyList);
setIsLoading(true);
}
}, [Moralis, Moralis.Web3, isAuthenticated]);
console.debug("Returning transactions: ", Txs);
console.groupEnd();
return { Txs, isLoading };
};
It must be an “inconvienience” function? Is TokenTransfers available as a server call? How do I go about calling it from my ReactJS front-end? Do I need to wrap my own server function around it? Any quick n’ easy examples you can point me to?
Please advise. Thanks!