-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Description Add basic viem documentation with link to [viem.sh/zksync](viem.sh/zksync)
- Loading branch information
1 parent
ed5fb2b
commit 74ea5bf
Showing
74 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
--- | ||
title: Getting Started | ||
description: | ||
tags: ["viem", "zksync", "sdks", "zksync era sdk", "era network"] | ||
links: | ||
- label: Viem Documentation | ||
to: https://viem.sh/zksync | ||
target: _blank | ||
--- | ||
|
||
Viem provides first-class support for the ZKsync chain. | ||
Full `viem/zksync` documentation is available at [viem.sh/zksync](https://viem.sh/zksync). | ||
|
||
## Installation | ||
|
||
First, install the `viem` package: | ||
|
||
```bash | ||
npm i viem | ||
``` | ||
|
||
## Client Setup | ||
|
||
### 1. Set up your Client & Transport | ||
|
||
Firstly, set up your [Client](https://viem.sh/docs/clients/intro) with a desired [Transport](https://viem.sh/docs/clients/intro) | ||
and extend it with ZKsync [EIP712 actions](https://viem.sh/zksync/client#eip712walletactions) | ||
|
||
```js | ||
import { createWalletClient, custom } from 'viem' | ||
import { zksync } from 'viem/chains' | ||
import { eip712WalletActions } from 'viem/zksync' | ||
|
||
const walletClient = createWalletClient({ | ||
chain: zksync, | ||
transport: custom(window.ethereum!), | ||
}).extend(eip712WalletActions()) | ||
``` | ||
|
||
### 2. Use Actions | ||
|
||
Now that you have a Client set up, you can send a transaction on ZKsync using a [paymaster](/zksync-protocol/account-abstraction/paymasters)! | ||
|
||
```js | ||
const hash = await walletClient.sendTransaction({ | ||
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', | ||
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', | ||
value: 1000000000000000000n, | ||
paymaster: '0xFD9aE5ebB0F6656f4b77a0E99dCbc5138d54b0BA', | ||
paymasterInput: '0x123abc...' | ||
}) | ||
``` | ||
|
||
...and even write to contracts: | ||
|
||
```js | ||
const hash = await walletClient.writeContract({ | ||
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', | ||
abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), | ||
functionName: 'mint', | ||
args: [69420], | ||
}) | ||
``` | ||
|
||
## Next Steps | ||
|
||
- Find full `viem/zksync` documentation with examples at [viem.sh/zksync](https://viem.sh/zksync) | ||
- Check out the [ZKsync SSO](/zksync-era/unique-features/zksync-sso) built on top of `viem` | ||
to improve UX for users of your app with just few lines of code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
title: Viem |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.