Skip to content
LogoLogo

tevm get-account

tevm get-account runs this operation: Get local account balance, nonce, code, and storage metadata. 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-account --address 0x1000000000000000000000000000000000000001 --return-storage --session docs --run --json

Output captured from the final command:

{
  "ok": true,
  "command": "get-account",
  "result": {
    "address": "0x1000000000000000000000000000000000000001",
    "balance": "1000000000000000000",
    "codeHash": "0xb651c70c9d4547c40705b18caf3faf5e9ced641e71bab674e665870b09938b1a",
    "isContract": true,
    "isEmpty": false,
    "deployedBytecode": "0x6080604052348015600e575f5ffd5b50600436106030575f3560e01c80633fb5c1cb1460345780638381f58a146045575b5f5ffd5b6043603f3660046098565b605e565b005b604c5f5481565b60405190815260200160405180910390f35b5f8190556040518181527f2fd81fd19d3c5c4b396dd13f451dafc8bcac1b3094c49c5fa90e68456323f0e39060200160405180910390a150565b5f6020828403121560a7575f5ffd5b503591905056fea26469706673582212203ef1a75b09ee91fb7f995d62885094508a883f40d776c10ba4f1d1427a64bd8b64736f6c63430008230033",
    "nonce": "7",
    "storageRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
    "storage": {
      "0x0000000000000000000000000000000000000000000000000000000000000000": "0x2a"
    }
  },
  "session": "docs"
}

Arguments and flags

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

KindSyntaxDescription
Flag--address <address>Ethereum address of the account to get (env: TEVM_ADDRESS)
Flag-r, --runRun directly without interactive parameter editing (env: TEVM_RUN) (default: false)
Flag--rpc [rpc]RPC endpoint (env: TEVM_RPC) (default: http://localhost:8545)
Flag--return-storageReturn account storage (can be expensive) (env: TEVM_RETURN_STORAGE) (default: false)
Flag--block-tag [block-tag]Block tag to fetch account from (latest, earliest, pending, etc.) (env: TEVM_BLOCK_TAG)
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 estimate-gas · tevm action get-balance