Skip to content
    traceBlock@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);

    // Example of using the traceBlock method
    const main = async () => {
    // The block to debug.
    let block = "latest";

    // Tracer type and configuration.
    let tracerConfig = {
    type: "callTracer",
    onlyTopCall: true,
    };

    // Calling the traceCall method
    let response = await alchemy.debug.traceBlock(block, tracerConfig);

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

    main();