6️⃣Token View (Optional)
Walkthrough for tracking token views
Setting Up Token View Tracking
// example of w3aSDK.tokenView
w3aSDK.tokenView({
label: "The Graph ($GRT)", // Optional: label for the token
chainId: "0x1", // Chain ID of the token
contractAddress: "0xc944e90c64b2c07662a292be6244bdf05cda44a7", // contract address of the token
});Practical Implementation
// w3aSDK.tokenView working example
import { useParams } from 'react-router-dom';
import { w3aSDK } from '@web3acquire/w3a';
const MAINNET_CHAIN_ID = "0x1";
const CHAIN_TO_CHAIN_ID = {
"ethereum": MAINNET_CHAIN_ID /* Mainnet chainId */
}
export const TokenViewPage = () => {
const { chain, contractAddress } = useParams();
React.useEffect(() => {
w3aSDK.tokenView({
chainId: CHAIN_TO_CHAIN_ID[chain],
contractAddress: contractAddress,
});
}, [chain, contractAddress]);
// ... rest of the component
}Last updated