Skip to content
LogoLogo

tevm get-storage-at

tevm get-storage-at runs this operation: Read a raw contract storage slot. Reach for it when you need the operation from a terminal, CI job, or shell script.

Working example

The commands below were run with @tevm/cli@1.0.0-rc.151. They create their own local prerequisites or use the named public endpoint, so no hidden process is required.

npm install --global @tevm/cli@1.0.0-rc.151
tevm session docs --local --json
mkdir -p src
cat > src/Counter.sol <<'SOLIDITY'
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
 
contract Counter {
    uint256 public number;
 
    event NumberChanged(uint256 number);
 
    function setNumber(uint256 next) public {
        number = next;
        emit NumberChanged(next);
    }
}
SOLIDITY
tevm compile --json
jq '.abi' artifacts/Counter.json > artifacts/Counter.abi.json
tevm set-account --address 0x1000000000000000000000000000000000000001 --balance 1000000000000000000 --session docs --run --json
tevm set-code --address 0x1000000000000000000000000000000000000001 --bytecode "$(jq -r '.deployedBytecode' artifacts/Counter.json)" --session docs --run --json
tevm set-storage-at --address 0x1000000000000000000000000000000000000001 --index 0x0 --value 0x2a --session docs --run --json
tevm get-storage-at --address 0x1000000000000000000000000000000000000001 --slot 0x0 --session docs --run --json

Output captured from the final command:

{
  "ok": true,
  "command": "get-storage-at",
  "result": "0x000000000000000000000000000000000000000000000000000000000000002a",
  "session": "docs"
}

Arguments and flags

The command schema in packages/tevm-cli/src/commands/getStorageAt.tsx exposes:

KindSyntaxDescription
Flag--address [address]Contract address to get storage from (env: TEVM_ADDRESS)
Flag--slot [slot]Storage slot to read (env: TEVM_SLOT)
Flag--block-tag [block-tag]Block tag (latest, pending, etc.) (env: TEVM_BLOCK_TAG)
Flag--block-number [block-number]Block number to get storage at (env: TEVM_BLOCK_NUMBER)
Flag-r, --runRun directly without interactive parameter editing (env: TEVM_RUN) (default: false)
Flag--rpc [rpc]RPC endpoint (env: TEVM_RPC)
Flag--jsonEmit the stable machine-readable JSON envelope (env: TEVM_JSON) (default: false)
Flag-h, --helpShow help

--json and --session <name> are global options accepted before routing. See the CLI overview for their environment-variable forms and execution model.

Neighbours

CLI overview · tevm get-gas-price · tevm get-transaction