Skip to content
    getTokenBalances - V3@AlchemyDocs
    index.js
    Packager files
    package-lock.json
    package.json
    Config files
    .replit
    replit.nix
    // Imports the Alchemy SDK
    const { Alchemy, Network } = require("alchemy-sdk");

    // Configures the Alchemy SDK
    const config = {
    apiKey: "alchemy-replit", // Replace with your API key
    network: Network.ETH_MAINNET, // Replace with your network
    };

    // Creates an Alchemy object instance with the config to use for making requests
    const alchemy = new Alchemy(config);

    const main = async () => {
    //Initialize variables for the parameters
    let vitalikAddress = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
    let usdcContract = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48";
    //Call the method to return the token balances for this address
    let response = await alchemy.core.getTokenBalances(vitalikAddress, [usdcContract])

    //Logging the response to the console
    console.log(response)
    };

    main();