Hey @frankking3679
Thanks for reaching out to us
To convert the code for Covalent API to Moralis API for this, will require 3 of our APIs to fetch native balance, ERC20 balance, and NFT balance of an address. The code will look like this:
import Moralis from 'moralis';
try {
await Moralis.start({
apiKey: "YOUR_API_KEY"
});
// wallet address
const address = "";
// chain
const chain = "0x1";
const { raw: nativeBalance } = await Moralis.EvmApi.balance.getNativeBalance({
chain,
address,
});
const { raw: erc20Balance } = await Moralis.EvmApi.token.getWalletTokenBalances({
chain,
address,
});
const { raw: nftBalance } = await Moralis.EvmApi.nft.getWalletNFTs({
chain,
format: "decimal",
mediaItems: false,
address,
});
console.log({ nativeBalance, erc20Balance, nftBalance });
} catch (e) {
console.error(e);
}
Hope this helps~