Skip to content

Commit

Permalink
Merge branch 'main' into java-documentation-factoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Ngozi-Txfusion authored Jul 16, 2024
2 parents af6905a + d9e2aae commit 8da9f68
Show file tree
Hide file tree
Showing 25 changed files with 1,140 additions and 829 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/quickstart/getting-started
to: /sdk/python/introduction/overview
---
Explore Nuxt built-in components for pages, layouts, head, and more.
::
Expand Down
2 changes: 1 addition & 1 deletion content/sdk/20.go/00.introduction/00.overview.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Overview
description: An introduction to `zksync2-go`
description: An introduction to zksync2-go
tags: ["zksync", "zksync2-go", "ethereum", "layer-2", "zero-knowledge rollups", "go library", "blockchain scalability", "crypto transactions"]
---

Expand Down
65 changes: 0 additions & 65 deletions content/sdk/30.python/00.getting-started.md

This file was deleted.

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

The ZKsync Python SDK is a powerful tool designed to facilitate interaction with the ZKsync Layer-2 scaling solution
on the Ethereum blockchain. Leveraging zero-knowledge proofs, ZKsync provides efficient, low-cost transactions while
ensuring security and scalability. This SDK makes it easier for developers to integrate and utilize ZKsync's advanced
features in their applications.

## 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 [Python SDK examples](https://github.com/zksync-sdk/zksync2-examples/tree/main/python) to quickly and
efficiently develop applications with the ZKsync protocol.
::

## Key features

- **Transaction management**: Easily create, sign, and send transactions on the ZKsync network.
- **Account operations**: Manage accounts, including creating, funding, and querying balances.
- **Token support**: Support for multiple tokens, enabling transfers and swaps.
- **Contract interaction**: Interact with smart contracts deployed on ZKsync.
- **Batch transactions**: Bundle multiple transactions to reduce costs and improve efficiency.
- **Security**: Leverage zero-knowledge proofs for enhanced security and privacy.
- **Scalability**: Benefit from the scalability improvements provided by the ZKsync Layer-2 solution.

### Additional resources

For more detailed information and advanced usage, refer to the [official ZKsync documentation](https://docs.zksync.io/sdk).

::callout{icon="i-heroicons-light-bulb"}
To use the `Python SDK`, visit the [Getting Started](/sdk/python/guides/getting-started) page.
::
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ The SDK is actively developed and maintained by the ZKsync team. This ensures th
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
Explore the [Python SDK documentation](/sdk/python/guides/getting-started) to get started and take advantage of all the
features and benefits it offers.
::
64 changes: 0 additions & 64 deletions content/sdk/30.python/00.quickstart/00.getting-started.md

This file was deleted.

This file was deleted.

51 changes: 51 additions & 0 deletions content/sdk/30.python/01.guides/00.getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: Getting Started
description: A guide to getting started with the ZKsync Python SDK.
tags: ["zksync", "python", "sdk", "getting started"]
---

This guide will help you get started with the ZKsync Python SDK, from connecting to the network to performing basic operations.

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

## Connecting to ZKsync Era

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

```python
from zksync2.module.module_builder import ZkSyncBuilder
...
sdk = ZkSyncBuilder.build("https://sepolia.era.zksync.dev")
```

Get chain id:

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

Get block number:

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

Get the transaction by hash:

```ts
transaction = zksync_web3.zksync.eth_get_transaction_by_hash(hash);
```

## Examples

Also, the following examples demonstrate 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)

Full code for all examples is available in the [Python ZKsync SDK](https://github.com/zksync-sdk/zksync2-examples/tree/main/python).
Examples are configured to interact with `ZKsync Era` and `Sepolia` test networks.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: ZKsync Era Features
description:
description: Unique features and differences of ZKsync Era compared to Ethereum.
tags: ["zksync", "ethereum", "sdk", "features"]
---

While ZKsync is mostly Web3-compatible, it has some differences compared to Ethereum. The major of those are:
Expand All @@ -22,7 +23,7 @@ While the paymaster feature by itself does not impose any limitations on values
the Matter Labs team endorses certain types of paymaster flows that are processable by EOAs.

ZKsync SDK provides a utility method that can be used to get the correctly formed `paymasterParams` object:
[PaymasterFlowEncoder](/sdk/python/paymaster-utils#paymasterflowencoder).
[PaymasterFlowEncoder](/sdk/python/api/utilities/paymaster-utils#paymasterflowencoder).

## See in action

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
title: Accounts | L1<->L2 Transactions
description:
title: L1<->L2 Transactions
description: Methods to facilitate transactions between L1 and L2 networks
tags: ["zksync", "l1", "l2", "transactions", "python", "sdk"]
---

This section explores the methods which allow the [account](/sdk/python/accounts)
This section explores the methods which allow the [account](/sdk/python/api/accounts/wallet)
classes to send transactions from L1 to L2.

If you want to get some background on how L1->L2 interaction works on ZKsync Era, go through the
Expand All @@ -14,34 +15,34 @@ Full examples of actions below are available on the getting started page.
## Deposit

`Wallet` object provides a deposit workflow. For more information, please refer to the
method specification [`Deposit`](/sdk/python/accounts#deposit).
method specification [`Deposit`](/sdk/python/api/accounts/wallet#deposit).

For a complete example of how to execute the deposit workflow, take a look at the following:
[Deposit ETH and ERC20 token](https://github.com/zksync-sdk/zksync2-examples/blob/main/python/01_deposit.py).

## Request execute

`Wallet` and `L1Signer` objects provide an option to request execution of L2 transaction from L1.
For more information, please refer to the method specification [`request_execute`](/sdk/python/accounts#requestexecute).
For more information, please refer to the method specification [`request_execute`](/sdk/python/api/accounts/wallet#requestexecute).

## Base cost

`Wallet` object provides an option to calculate base cost for L2 transaction. For more information, please refer to the
method specification [`getBaseCost`](/sdk/python/accounts#getbasecost).
method specification [`getBaseCost`](/sdk/python/api/accounts/wallet#getbasecost).

## Claim failed deposit

`Wallet` object provides a claim fail deposit workflow. For more information, please refer to the method specification
[`claimFailedDeposit`](/sdk/python/accounts#claimfaileddeposit).
[`claimFailedDeposit`](/sdk/python/api/accounts/wallet#claimfaileddeposit).

## Finalize withdraw

`Wallet` object provides a finalize withdraw workflow. For more information, please refer to the method specification
[`finalizeWithdrawal`](/sdk/python/accounts#finalizewithdrawal).
[`finalizeWithdrawal`](/sdk/python/api/accounts/wallet#finalizewithdrawal).

## Withdrawal

`Wallet` object provides a withdrawal workflow. For more information, please refer to the method specification [`Deposit`](/sdk/python/accounts#deposit).
`Wallet` object provides a withdrawal workflow. For more information, please refer to the method specification [`Deposit`](/sdk/python/api/accounts/wallet#deposit).

For a complete example of how to execute the deposit workflow, take a look at the following:
[Withdraw ETH and ERC20 token](https://github.com/zksync-sdk/zksync2-examples/blob/main/python/09_withdrawal.py).
21 changes: 21 additions & 0 deletions content/sdk/30.python/02.api/00.providers/00.introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: Introduction
description: Overview of Web3Providers and their functions.
tags: ["web3", "blockchain", "provider", "zksync"]
---

A Web3 Provider object provides application-layer access to underlying blockchain networks. It serves as a crucial
interface for interacting with various blockchain functionalities, enabling developers to connect, communicate, and
perform operations on the blockchain.

The [`zksync2`](https://pypi.org/project/zksync2/) library supports provider methods from
the [`web3.py`](https://web3py.readthedocs.io/en/stable/providers.html) library and supplies additional functionality
tailored for the ZKsync Era network.

### Key features

- **Network connectivity:** Establishes connections to blockchain networks, allowing applications to interact with them.
- **Transaction management:** Facilitates the creation, sending, and tracking of transactions.
- **Gas estimation:** Provides estimations for the amount of gas required for transactions.
- **Account management:** Retrieves balances and transaction histories for accounts.
- **Contract interaction:** Enables interaction with smart contracts, including deploying and calling contract methods.
Loading

0 comments on commit 8da9f68

Please sign in to comment.