0

I have deployed the contract and I'm trying to get the address at each storage slot


module.exports = async ({ getNamedAccounts, deployments }) => {
    const { deploy, log } = deployments
    const { deployer } = await getNamedAccounts()

    log("----------------------------------------------------")
    log("Deploying FunWithStorage and waiting for confirmations...")
    const funWithStorage = await deploy("FunWithStorage", {
        from: deployer,
        args: [],
        log: true,
        // we need to wait if on a live network so we can verify properly
        waitConfirmations: network.config.blockConfirmations || 1,
    })
    
    if (!developmentChains.includes(network.name) && process.env.ETHERSCAN_API_KEY) {
        await verify(funWithStorage.address, [])
    }

    log("Logging storage...")
    for (let i = 0; i < 10; i++) {
        log(
            `Location ${i}: ${await ethers.provider.getStorageAt(
                funWithStorage.address,
                i
            )}`

        )
    }

1 Answer 1

1

In Ethers V6 it's now getStorage

await provider.getStorage(address, slot);

Check out this documentation for reference https://docs.ethers.org/v6/api/providers/#Provider-getStorage

2
  • Thanks Zartaj , its working ..
    – MD AZAD
    Commented Oct 9, 2023 at 15:14
  • Awesome, you can checkmark the answer :) Commented Oct 10, 2023 at 4:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.