Skip to content

Commit

Permalink
Merge branch 'main' into update-the-js-v5-page
Browse files Browse the repository at this point in the history
  • Loading branch information
danijelTxFusion authored Jun 27, 2024
2 parents 5c8a272 + dd1b155 commit 7d85a36
Show file tree
Hide file tree
Showing 13 changed files with 316 additions and 148 deletions.
2 changes: 1 addition & 1 deletion content/sdk/00.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Integrate ZKsync GO SDK for ZKsync Era features.
---
title: Python
icon: i-heroicons-circle-stack
to: /sdk/python/getting-started
to: /sdk/python/quickstart/getting-started
---
Explore Nuxt built-in components for pages, layouts, head, and more.
::
Expand Down
2 changes: 1 addition & 1 deletion content/sdk/10.js/00.ethers/00.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ support common operations developers require and serve as an excellent starting
There are two main versions of the zksync-ethers SDK: V5 and V6. Each version caters to different needs and provides
distinct features and improvements.

::callout
::callout{icon="i-heroicons-light-bulb"}
Check out the [installation guide](/sdk/js/ethers/installation-js) for installation instructions.
::

Expand Down
2 changes: 1 addition & 1 deletion content/sdk/10.js/00.ethers/01.why-zksync-ethers.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ features and improvements, ensuring compatibility with future advancements in ZK
technologies. The SDK is regularly updated to incorporate the latest developments, providing developers with a
powerful and flexible tool for building next-generation blockchain applications.

::callout
::callout{icon="i-heroicons-light-bulb"}
Explore the [zksync-ethers documentation](/sdk/js/ethers) to get started and take advantage of all the
features and benefits it offers.
::
2 changes: 1 addition & 1 deletion content/sdk/10.js/00.ethers/02.installation-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tags: ["zksync", "installation", "setup", "ethereum", "sdk"]
Learn how to install and set up the `zksync-ethers` library to interact with the ZKsync network, leveraging its
features for Ethereum scaling and Layer 2 solutions.

::callout
::callout{icon="i-heroicons-light-bulb"}
If you're migrating from `zksync-web3`, please refer to the [migration guide](/sdk/js/ethers/v6/migration) for detailed instructions.
::

Expand Down
31 changes: 31 additions & 0 deletions content/sdk/10.js/00.ethers/03.compatibility-js.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: Platform Compatibility
description: Platforms compatible with zksync-ethers v5 and v6
tags: ["compatibility", "ethers.js", "zksync"]
---

`zksync-ethers` supports all modern browsers (Chrome, Edge, Firefox, Safari, etc.) & runtime
environments (Node.js, React Native, Electron).

## Ethers v5 compatibility

- **Node.js**: v12.x and above.
- **Browser**: All modern browsers (Chrome, Firefox, Safari, Edge).
- **React Native**: Supported via `react-native-ethers`.
- **Electron**: Standard configurations supported.
- **TypeScript**: Included type definitions.

## Ethers v6 compatibility

- **Node.js**: v14.x and above
- **Browser**: Optimized for all modern browsers.
- **React Native**: Improved support via the latest `react-native-ethers`.
- **Electron**: Enhanced integration for desktop applications.
- **TypeScript**: Comprehensive type definitions for better developer experience.
- **BigInt**: Required for certain functionalities in ethers v6.

Both versions offer robust platform compatibility, ensuring seamless integration with ZKsync across different environments.

::callout{icon="i-heroicons-light-bulb"}
For more detailed information and specific configurations, refer to the [official zksync-ethers documentation](https://zksync.io/sdk/js/ethers).
::
65 changes: 0 additions & 65 deletions content/sdk/30.python/00.getting-started.md

This file was deleted.

60 changes: 60 additions & 0 deletions content/sdk/30.python/00.quickstart/00.getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: Overview
description: An introduction to the ZKsync Python SDK and its features.
tags: ["zksync", "python", "sdk", "overview"]
---

## Concept

Most existing SDKs work right away, but deploying smart contracts or using unique ZKsync features, like account
abstraction, needs extra fields that Ethereum transactions don't have by default.

To make it easy to use all ZKsync Era features, we created the `zksync2` Python SDK. This SDK has an interface similar
to [web3.py](https://web3py.readthedocs.io/en/latest/index.html). In fact, `web3.py` is a peer dependency of our
library. Most objects exported by `zksync2` inherit from `web3.py` objects and only change the fields that need adjustments.

::callout{icon="i-heroicons-light-bulb"}
Explore the [installation guide](https://github.com/zksync-sdk/zksync2-examples/tree/main/python) to get started with
the ZKsync Python SDK.
::

## Connecting to ZKsync Era

Once you have all the necessary dependencies, connect to ZKsync Era using the operator node endpoint.

```python
from zksync2.module.module_builder import ZkSyncBuilder

sdk = ZkSyncBuilder.build("https://sepolia.era.zksync.dev")
```

Get the chain ID:

```python
chain_id = zk_web3.zksync.chain_id
```

Get the block number:

```python
block_number = zk_web3.zksync.block_number
```

Get the transaction by hash:

```python
transaction = zk_web3.zksync.eth_get_transaction_by_hash(hash)
```

## Examples

These examples show how to:

1. [Deposit ETH and tokens from Ethereum into ZKsync Era](https://github.com/zksync-sdk/zksync2-examples/blob/main/python/01_deposit.py)
2. [Transfer ETH and tokens on ZKsync Era](https://github.com/zksync-sdk/zksync2-examples/blob/main/python/02_transfer.py)
3. [Withdraw ETH and tokens from ZKsync Era to Ethereum](https://github.com/zksync-sdk/zksync2-examples/blob/main/python/09_withdrawal.py)
4. [Use paymaster to pay fees with tokens](https://github.com/zksync-sdk/zksync2-examples/blob/main/python/15_use_paymaster.py)

You can find the full code for all examples in
the [Python ZKsync SDK](https://github.com/zksync-sdk/zksync2-examples/tree/main/python). These examples are set up to
work with `ZKsync Era` and `Sepolia` test networks.
45 changes: 45 additions & 0 deletions content/sdk/30.python/00.quickstart/01.why-python-sdk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: Why Python SDK
description: Benefits and features of Python SDK for ZKsync Era.
tags: ["zksync", "ethers", "sdk", "python"]
---

### Easy integration

The ZKsync Python SDK integrates seamlessly with your existing Python projects. Its interface is similar to the
popular [web3.py](https://web3py.readthedocs.io/en/latest/index.html) library, making it easy for developers
familiar with Ethereum development to get started quickly.

### Comprehensive functionality

The SDK gives you access to all the unique features of ZKsync Era, including:

- **Account abstraction**: Deploy and manage smart contracts with extra fields that standard Ethereum transactions
don't have.
- **Optimized performance**: Benefit from ZKsync's scalability and speed improvements directly through the SDK.

### Consistent API

The SDK maintains a consistent API with `web3.py`, ensuring a smooth transition and reducing the learning curve. Most
objects exported by `zksync2` inherit from `web3.py` objects, with only necessary modifications.

### Strong community support

As part of the ZKsync ecosystem, the Python SDK benefits from strong [community support](https://join.zksync.dev/)
and regular updates. You can
find extensive documentation, examples, and a helpful community ready to assist you.

### Security and reliability

The ZKsync Python SDK is built with security and reliability in mind. It leverages ZKsync’s robust infrastructure to
ensure secure and reliable transactions and interactions with the blockchain.

### Active development

The SDK is actively developed and maintained by the ZKsync team. This ensures that you always have access to the
latest features and improvements, keeping your projects up to date with the evolving blockchain landscape.

::callout{icon="i-heroicons-light-bulb"}
Explore the [Python SDK documentation](/sdk/python/quickstart/getting-started) to get started and take advantage of all the
features and benefits it offers.
::
41 changes: 41 additions & 0 deletions content/sdk/30.python/00.quickstart/02.installation-python.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: Installation
description: How to install and set up Python SDK for your project.
tags: ["zksync", "installation", "setup", "python", "sdk"]
---

## Prerequisites

Make sure you have the following software installed on your system:

- **Python**: Version 3.8 or higher. Download and install it from the [Python website](https://www.python.org/downloads/).
- **Pip**: Version 23.1.2 or higher. Pip is the package installer for Python. Install it using the guide on the [Pip website](https://pip.pypa.io/en/stable/installation/).

## Adding dependencies

To add the ZKsync Era SDK to your project, follow these steps:

1. **Open your terminal**: Use any terminal or command line interface you like.

2. **Install the ZKsync Era SDK**: Run this command to install the SDK with pip:

```shell
pip install zksync2
```

## Verification

Check if the installation was successful by importing the SDK in a Python script or an interactive Python session:

```python
import importlib.metadata

zksync_version = importlib.metadata.version("zksync2")
print("ZKsync SDK version:", zksync_version)
```

You should see a response like:

```sh
ZKsync SDK version: 1.2.0
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: Platform Compatibility
description: Platforms compatible with Python SDK
tags: ["compatibility", "python", "zksync"]
---

The ZKsync Python SDK supports various platforms to ensure smooth integration and functionality. Here are the details:

## Compatible platforms

### Operating systems

- **Windows**: Fully supported on Windows 10 and later versions.
- **macOS**: Fully supported on macOS 10.15 (Catalina) and later versions.
- **Linux**: Compatible with major distributions like Ubuntu, Debian, Fedora, and CentOS.

### Python versions

- **Python 3.8**: Supported
- **Python 3.9**: Supported
- **Python 3.10**: Supported
- **Python 3.11**: Supported

### Development Environments

- **IDEs**: Works well with popular Integrated Development Environments like PyCharm, VSCode, and Atom.
- **Virtual environments**: Compatible with virtual environment tools like `venv` and `virtualenv`.

### Additional dependencies

The SDK relies on certain dependencies to ensure full functionality. Make sure you have these installed:

- **web3.py**: A peer dependency required by `zksync2`.

```shell
pip install web3
```
19 changes: 9 additions & 10 deletions content/sdk/70.faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ ZKsync Era SDKs are toolkits designed to help developers build decentralized app
Era network. They provide the necessary libraries and tools to interact with ZKsync.

### How do I get started with ZKsync Era SDKs?
You can start by visiting the official ZKsync documentation, which provides comprehensive guides, tutorials, and API
references to help you begin building dApps on ZKsync Era.
You can start by visiting the [official ZKsync documentation](/sdk), which provides comprehensive guides, tutorials,
and API references to help you begin building dApps on ZKsync Era.

### What types of dApps can be built using ZKsync Era SDKs?
ZKsync Era SDKs can be used to build a variety of dApps, including DeFi protocols, NFT marketplaces, gaming
applications, and more, leveraging Ethereum smart contract capabilities.
### How do I connect to ZKsync Era using the Python SDK?

### Can ZKsync Era be used for NFT applications?
Yes, ZKsync Era supports the ERC-721 standard, enabling the development of NFT applications on its platform.
To connect to ZKsync Era, use the operator node endpoint. Here is an example of how to set it up:

### How does ZKsync Era handle data availability?
ZKsync Era uses off-chain storage for most data, with periodic updates and validity proofs submitted to the Ethereum
mainnet to ensure data availability and security.
```python
from zksync2.module.module_builder import ZkSyncBuilder

sdk = ZkSyncBuilder.build("https://sepolia.era.zksync.dev")
```
Loading

0 comments on commit 7d85a36

Please sign in to comment.