Skip to main content
Viem is a TypeScript Interface for Ethereum that provides low-level stateless primitives for interacting with Ethereum. You can use Tenderly with Viem to interact with the blockchain using standard RPC methods, as well as custom methods available on Node RPC. Call Viem’s createPublicClient and pass the following arguments:
  • chain: one of the pre-defined chains from viem/chains
  • transport: either a call to http or webSocket, and initialize with the https or wss RPC URL.

Code samples: Using Viem with Node RPC

node/samples/viem/0-a-call.ts

Batching requests

Viem allows you to send batch requests. With batching, several JSON-RPC calls are processed in a single HTTPS request. Several Viem actions will be batched and executed at the end of the current JavaScript message queue. By default, there’s no time delay, but is possible to configure via an optional wait parameter. This means that several viem actions will be batched and executed at the end of current JavaScript message queue. By default, there’s no time-delay, but is possible to configure via an optional wait parameter.
node/samples/viem/0-batch-calls.ts

Simulate transactions using viem

To use Simulation RPC methods, simply use the client.request method:
node/samples/viem/1-simulate.ts

Trace transactions using Viem

Use tenderly_traceTransaction to get fully decoded transaction trace.
node/samples/viem/2-transaction-trace.ts