@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@1.0.0-rc.151 @tevm/node@1.0.0-rc.151 viemAPI Reference
Core Functions
ethActions()- standard Ethereum JSON-RPC methods.requestEip1193()- EIP-1193 provider extension.tevmActions()- Tevm-specific actions.tevmSend()- send Tevm JSON-RPC requests.
Provider Types
Action Types
RPC Schema Types
RpcSchemaRpcSchemaOverrideDerivedRpcSchemaJsonRpcSchemaPublicJsonRpcSchemaTevmJsonRpcSchemaWalletTestRpcSchema
Ethereum Types
Utility Types
Usage Examples
import { createTevmNode } from '@tevm/node'
import { requestEip1193, ethActions, tevmActions } from '@tevm/decorators'
const node = createTevmNode()
const eip1193Node = node.extend(requestEip1193())
const chainId = await eip1193Node.request({ method: 'eth_chainId' })
const ethNode = node.extend(ethActions())
const balance = await ethNode.eth.getBalance({
address: '0x1111111111111111111111111111111111111111',
})
const tevmNode = node.extend(tevmActions())
await tevmNode.setAccount({
address: '0x1111111111111111111111111111111111111111',
balance: 1n,
})
const account = await tevmNode.getAccount({
address: '0x1111111111111111111111111111111111111111',
})
console.log(chainId, balance, account.balance)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://...'],
}
