Skip to content

Commit 7af016c

Browse files
David Magalhãesspeeddragonroberts-pumpursmariopil
committed
feat: EIP712 signing capabilities
Co-authored-by: David Magalhães <speeddragon@gmail.com> Co-authored-by: Roberts Ivanovs <robertsivanovs1999@gmail.com> Co-authored-by: Mariusz Pilarek <mariusz@eiger.co>
1 parent 45884d5 commit 7af016c

28 files changed

+3341
-12
lines changed

site/.vitepress/config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ export default defineConfig({
7575

7676
nav: [
7777
{ text: 'Docs', link: '/docs/getting-started', activeMatch: '/docs' },
78+
{
79+
activeMatch: '/zksync',
80+
text: 'Extensions',
81+
items: [
82+
{
83+
activeMatch: '/zksync',
84+
text: 'zkSync',
85+
link: '/zksync',
86+
},
87+
],
88+
},
7889
{
7990
activeMatch: '/op-stack',
8091
text: 'Extensions',

site/.vitepress/sidebar.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,41 @@ export const sidebar: DefaultTheme.Sidebar = {
925925
],
926926
},
927927
],
928+
'/zksync': [
929+
{ text: '← Viem Docs', link: '/docs/getting-started' },
930+
{
931+
text: 'zkSync',
932+
items: [
933+
{
934+
text: 'Getting started',
935+
link: '/zksync',
936+
},
937+
{ text: 'Client', link: '/zksync/client' },
938+
{ text: 'Chains', link: '/zksync/chains' },
939+
],
940+
},
941+
{
942+
text: 'Actions',
943+
items: [
944+
{
945+
text: 'prepareEip712TransactionRequest',
946+
link: '/zksync/actions/prepareEip712TransactionRequest',
947+
},
948+
{
949+
text: 'sendEip712Transaction',
950+
link: '/zksync/actions/sendEip712Transaction',
951+
},
952+
{
953+
text: 'signEip712Transaction',
954+
link: '/zksync/actions/signEip712Transaction',
955+
},
956+
{
957+
text: 'writeEip712Contract',
958+
link: '/zksync/actions/writeEip712Contract',
959+
},
960+
],
961+
},
962+
],
928963
'/op-stack': [
929964
{ text: '← Viem Docs', link: '/docs/getting-started' },
930965
{

site/zksync.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
head:
3+
- - meta
4+
- property: og:title
5+
content: Getting started
6+
- - meta
7+
- name: description
8+
content: Getting started with the zkSync in Viem
9+
- - meta
10+
- property: og:description
11+
content: Getting started with the zkSync in Viem
12+
---
13+
14+
# Getting started with zkSync
15+
16+
Viem provides first-class support for the [zkSync](https://zksync.io) chain.
17+
18+
zkSync is a Layer-2 protocol that scales Ethereum with cutting-edge ZK tech.
19+
20+
## Quick Start
21+
22+
### 1. Set up your Client & Transport
23+
24+
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.
25+
26+
```ts {5-8}
27+
import { createWalletClient, custom } from 'viem'
28+
import { zkSync } from 'viem/chains'
29+
import { eip712Actions } from 'viem/chains/zksync'
30+
31+
const client = createWalletClient({
32+
chain: zkSync,
33+
transport: custom(window.ethereum),
34+
}).extend(eip712Actions())
35+
```
36+
37+
::: info
38+
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).
39+
:::
40+
41+
### 2. Send transactions using paymaster
42+
43+
Now that you have a Client set up, you can [send a transaction](./zksync/actions/sendEip712Transaction.md) using a paymaster! [Read more](./zksync/client.md)
44+
45+
```ts
46+
const hash = await client.sendEip712Transaction({
47+
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
48+
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
49+
value: 1000000000000000000n,
50+
paymaster: '0xFD9aE5ebB0F6656f4b77a0E99dCbc5138d54b0BA',
51+
paymasterInput: '0x123abc...'
52+
})
53+
```

0 commit comments

Comments
 (0)