Viem SDK

Interact with the Lens Network using Viem.


The Lens Network SDK offers first-class support for Viem, a popular TypeScript Interface for Ethereum. Specifically, it adopts Viem paradigms and provides stateless, low-level primitives for interacting with the Lens Network.

This section presumes that you are familiar with the client-action architecture of Viem.

Getting Started

1

Install Viem

First, install Viem package:

npm install viem@2

2

Install SDK

Then, install the @lens-network/sdk package:

npm install @lens-network/sdk@canary

3

Create a Client

Next, configure your Client by selecting the desired Transport and a Lens Network Chain.

import { createPublicClient, http } from "viem";import { chains } from "@lens-network/sdk/viem";
export const publicClient = createPublicClient({  chain: chains.testnet,  transport: http(),});

4

Use Lens Network Actions

With your Clients now set up, you're ready to interact with the Lens Network and consume Actions.

Example
import { sendRawTransactionWithDetailedOutput } from "@lens-network/sdk/viem";
import { walletClient } from "./walletClient";
const result = await sendRawTransactionWithDetailedOutput(walletClient, {  serializedTransaction: "0x02f8500182031180…",});

Actions

The Lens Network SDK is designed to enable you to consume standard Viem Actions for general EVM features, as well as ZKsync-specific Actions, such as:

Custom RPC Node

If you want to use a Lens Network RPC node other than the default one, you can specify the custom RPC node URL in the http transport.

import { createPublicClient, http } from "viem";import { chains } from "@lens-network/sdk/viem";
export const publicClient = createPublicClient({  chain: chains.testnet,  transport: http("https://custom-rpc-node.com"),});