Skip to content
    estimateGas@AlchemyDocs
    index.js
    Packager files
    package-lock.json
    package.json
    Config files
    .replit
    replit.nix
    // Imports the Alchemy SDK
    const { Alchemy, Network, Utils } = 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 () => {
    //Define the params object
    const params = {
    // Wrapped ETH address
    to: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
    // `function deposit() payable`
    data: "0xd0e30db0",
    // 1 ether
    value: Utils.parseEther("1.0"),
    };

    //The response returns the block number of the most recently mined block
    let response = await alchemy.core.estimateGas(params)

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

    main();