Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

@tevm/decorators

Action decorators for extending Tevm clients: EIP-1193 providers, Ethereum JSON-RPC methods, and Tevm-specific actions.

Full API: packages/decorators/docs.

Installation

npm install @tevm/decorators

API Reference

Core Functions

Provider Types

Action Types

RPC Schema Types

Ethereum Types

Utility Types

Usage Examples

import { requestEip1193, ethActions, tevmActions } from '@tevm/decorators'
 
const eip1193Client = createClient({ transport: requestEip1193() })
const result = await eip1193Client.request({
  method: 'eth_call',
  params: [{ to: '0x...', data: '0x...' }],
})
 
const ethClient = createClient({ transport: ethActions() })
const balance = await ethClient.eth.getBalance({ address: '0x...' })
const code = await ethClient.eth.getCode({ address: '0x...' })
 
const tevmClient = createClient({ transport: tevmActions() })
const call = await tevmClient.transport.tevm.call({ to: '0x...', data: '0x...' })
const state = await tevmClient.transport.tevm.dumpState()

Error Codes

try {
  await client.request({ method: 'eth_call', params: [{ to: '0x...', data: '0x...' }] })
} catch (error) {
  if (error.code === 4001) {
    // user rejected
  } else if (error.code === -32000) {
    // execution error
  }
}

Chain Parameters

const chainParams: AddEthereumChainParameter = {
  chainId: '0x1',
  chainName: 'Ethereum Mainnet',
  nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
  rpcUrls: ['https://...'],
}

See Also