createPublicClient and pass the following arguments:
chain: one of the pre-defined chains fromviem/chainstransport: either a call tohttporwebSocket, and initialize with thehttpsorwssRPC 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 optionalwait 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 theclient.request method:
node/samples/viem/1-simulate.ts
Trace transactions using Viem
Usetenderly_traceTransaction to get fully decoded transaction trace.
node/samples/viem/2-transaction-trace.ts