Skip to content
v0.5.0

Ethereum Virtual Script

Write read-only EVM scripts in TypeScript. evs compiles them to bytecode and runs them as one eth_call, so reads that depend on earlier reads cost a single round trip.
bun add @maxencerb/evs viem
One eth_call
Dependent reads run inside a single RPC round trip.
Typed through viem
The script is its own ABI; readContract infers args and result.
Nothing to deploy
Deployless by default, state override when msg.sender matters.
solc 0.8 semantics
Checked arithmetic, verbatim revert bubbling, panic codes.

Read a Uniswap V3 pool’s two tokens, then each token’s symbol.

script.ts
import { evscript, t } from '@maxencerb/evs';
import { erc20Abi } from 'viem';
import { poolAbi } from './abi';
export const poolTokens = evscript(
{ name: 'poolTokens', args: [t.address] },
(s, pool) => {
const token0 = s.read({ address: pool, abi: poolAbi, functionName: 'token0' });
const token1 = s.read({ address: pool, abi: poolAbi, functionName: 'token1' });
const symbol0 = s.read({ address: token0, abi: erc20Abi, functionName: 'symbol' });
const symbol1 = s.read({ address: token1, abi: erc20Abi, functionName: 'symbol' });
return s.return({ token0, token1, symbol0, symbol1 });
},
);

A multicall encodes every call before the request leaves, so it cannot read symbol from an address that the same batch returns.