The code below is s short version for collecting the NFT “to” transfers for Ether as well as Polygon mainnet for the same wallet address.
But the “total” shows the same value for Ether and Polygon (both 1662) which is not the case, as Polygon has total of 1662 (as of today) and Ether a total of 22 (as also shown in “results” as of today):
Here the code:
<!DOCTYPE html>
<html>
<head>
<title>Vanilla Boilerplate</title>
<script src="https://unpkg.com/moralis/dist/moralis.js"></script>
</head>
<body>
<h1>Moralis Hello World!</h1>
<button id="btn-startFunc">Start</button>
</body>
<script type="text/javascript">
/** Connect to Moralis server */
const serverUrl = "add_here";
const appId = "add_here";
Moralis.start({ serverUrl, appId });
async function startFunc() {
const optionsPolygon2 = { chain: "polygon", direction: "to", address: "0xa400f50d2c9cba8c7c125be8b37ff04edff5a018" };
let transfersNFTPolygon = await Moralis.Web3API.account.getNFTTransfers(optionsPolygon2);
console.log(transfersNFTPolygon)
const optionsEthereum2 = { chain: "eth", direction: "to", address: "0xa400f50d2c9cba8c7c125be8b37ff04edff5a018", limit: 100 };
let transfersNFTEthereum = await Moralis.Web3API.account.getNFTTransfers(optionsEthereum2);
console.log(transfersNFTEthereum)
}
document.getElementById("btn-startFunc").onclick = startFunc;
</script>
</html>