Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ VITE_ANVIL_FORK_URL=
VITE_ANVIL_BLOCK_TIME=1
VITE_ANVIL_BLOCK_NUMBER=16280770
VITE_ANVIL_BLOCK_NUMBER_OPTIMISM=112157024
VITE_ANVIL_BLOCK_NUMBER_ZKSYNC=25734
VITE_ANVIL_PORT=8545
VITE_ANVIL_PORT_OPTIMISM=8645
VITE_ANVIL_PORT_ZKSYNC=8745
VITE_BATCH_JSON_RPC=false
VITE_BATCH_MULTICALL=false
VITE_NETWORK_TRANSPORT_MODE=http
VITE_RPC_URL_OPTIMISM=
VITE_ANVIL_FORK_URL_OPTIMISM=
VITE_ANVIL_FORK_URL_ZKSYNC=
5 changes: 5 additions & 0 deletions site/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ export default defineConfig({
text: 'OP Stack',
link: '/op-stack',
},
{
activeMatch: '/zksync',
text: 'zkSync',
link: '/zksync',
},
],
},
{
Expand Down
31 changes: 31 additions & 0 deletions site/.vitepress/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,37 @@ export const sidebar: DefaultTheme.Sidebar = {
],
},
],
'/zksync': [
{ text: '← Viem Docs', link: '/docs/getting-started' },
{
text: 'zkSync',
items: [
{
text: 'Getting started',
link: '/zksync',
},
{ text: 'Client', link: '/zksync/client' },
{ text: 'Chains', link: '/zksync/chains' },
],
},
{
text: 'Actions',
items: [
{
text: 'prepareTransactionRequest',
link: '/zksync/actions/prepareTransactionRequest',
},
{
text: 'sendTransaction',
link: '/zksync/actions/sendTransaction',
},
{
text: 'signTransaction',
link: '/zksync/actions/signTransaction',
},
],
},
],
'/op-stack': [
{ text: '← Viem Docs', link: '/docs/getting-started' },
{
Expand Down
53 changes: 53 additions & 0 deletions site/zksync.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
head:
- - meta
- property: og:title
content: Getting started
- - meta
- name: description
content: Getting started with the zkSync in Viem
- - meta
- property: og:description
content: Getting started with the zkSync in Viem
---

# Getting started with zkSync

Viem provides first-class support for the [zkSync](https://zksync.io) chain.

zkSync is a Layer-2 protocol that scales Ethereum with cutting-edge ZK tech.

## Quick Start

### 1. Set up your Client & Transport

Firstly, set up your [Client](/docs/clients/intro) with a desired [Transport](/docs/clients/intro) & [zkSync Chain](./zksync/chains.md) and extend it with zkSync EIP712 actions.

```ts {5-8}
import { createWalletClient, custom } from 'viem'
import { zkSync } from 'viem/chains'
import { eip712Actions } from 'viem/chains/zksync'

const client = createWalletClient({
chain: zkSync,
transport: custom(window.ethereum),
}).extend(eip712Actions)
```

::: info
In a production app, it is highly recommended to pass through your authenticated RPC provider URL (Alchemy, Infura, Ankr, etc). If no URL is provided, viem will default to a public RPC provider. [Read more](/docs/clients/transports/http.html#usage).
:::

### 2. Send transactions using paymaster

Now that you have a Client set up, you can [send a transaction](./zksync/actions/sendTransaction.md) using a paymaster! [Read more](./zksync/client.md)

```ts
const hash = await client.sendTransaction({
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: 1000000000000000000n,
paymaster: '0xFD9aE5ebB0F6656f4b77a0E99dCbc5138d54b0BA',
paymasterInput: '0x123abc...'
})
```
Loading