Skip to main content

getStorageAt

Callable

  • getStorageAt<ReturnFormat>(web3Context: Web3Context<EthExecutionAPI, any>, address: string, storageSlot: Numbers, blockNumber?: BlockNumberOrTag, returnFormat: ReturnFormat): Promise<string>

  • Get the storage at a specific position of an address.


    Type parameters

    • ReturnFormat: DataFormat

    Parameters

    • web3Context: Web3Context<EthExecutionAPI, any>

      (Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.

    • address: string

      The address to get the storage from.

    • storageSlot: Numbers

      The index position of the storage.

    • blockNumber: BlockNumberOrTag = web3Context.defaultBlock

      (BlockNumberOrTag defaults to Web3Eth.defaultBlock) Specifies what block to use as the current state for the storage query.

    • returnFormat: ReturnFormat

      (DataFormat defaults to DEFAULT_RETURN_FORMAT) Specifies how the return data should be formatted.

    Returns Promise<string>

    The value in storage at the given position.

    web3.eth.getStorageAt("0x033456732123ffff2342342dd12342434324234234fd234fd23fd4f23d4234", 0).then(console.log);
    > "0x033456732123ffff2342342dd12342434324234234fd234fd23fd4f23d4234"

    web3.eth.getStorageAt(
    "0x033456732123ffff2342342dd12342434324234234fd234fd23fd4f23d4234",
    0,
    undefined,
    { number: FMT_NUMBER.HEX , bytes: FMT_BYTES.BUFFER }
    ).then(console.log);
    > <Buffer 03 34 56 73 21 23 ff ff 23 42 34 2d d1 23 42 43 43 24 23 42 34 fd 23 4f d2 3f d4 f2 3d 42 34>