Tevm account management

From cyotee/indexedex · View interactive version

Tevm account management is an AI agent skill from the GitHub repository cyotee/indexedex. Get and set account state including balances, nonces, and storage. Use when manipulating EVM state for testing.

How to use this skill

Skill file

Account Management

getAccountHandler

Get current account state:

import { getAccountHandler } from 'tevm/actions'

const account = await getAccountHandler(node)({
  address: '0x...',
  blockTag: 'latest',
  returnStorage: true
})

Returns:

{
  address: Address
  nonce: bigint
  balance: bigint
  deployedBytecode: Hex
  storageRoot: Hex
  codeHash: Hex
  isContract: boolean
  isEmpty: boolean
  storage?: { [key: Hex]: Hex }
}

setAccountHandler

Modify account state:

import { setAccountHandler } from 'tevm/actions'

// Set balance
await setAccountHandler(node)({
  address: '0x...',
  balance: parseEther('100')
})

// Deploy contract code
await setAccountHandler(node)({
  address: contractAddress,
  deployedBytecode: '0x...',
  state: { '0x0': '0x1' }
})

// Multiple properties
await setAccountHandler(node)({
  address: '0x...',
  nonce: 5n,
  balance: parseEther('10'),
  state: { [slot]: value }
})

Account Impersonation (Fork Mode)

// Impersonate an account
node.setImpersonatedAccount('0x123...')

// Now JSON-RPC calls execute as that account
const result = await node.request({
  method: 'eth_sendTransaction',
  params: [{ from: '0x123...', to: '0x456...', ... }]
})

// Stop impersonating
node.setImpersonatedAccount(undefined)

State Snapshots

// Take snapshot
const snapshotId = await client.snapshot()

// Make changes
await setAccountHandler(node)({ address: '0x...', balance: 0n })

// Revert to snapshot
await client.revert({ id: snapshotId })
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.