Skip to content

Commit

Permalink
fix: edit urls
Browse files Browse the repository at this point in the history
  • Loading branch information
Ngozi-Txfusion committed Jul 10, 2024
1 parent c548e2c commit 0499e05
Show file tree
Hide file tree
Showing 12 changed files with 594 additions and 629 deletions.
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.
::
14 changes: 8 additions & 6 deletions content/sdk/30.python/01.guides/00.getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ 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/quickstart/installation-python) for instructions.
Check the [installation guide](/sdk/python/introduction/installation) for instructions.
::

## Connecting to ZKsync Era
Expand Down Expand Up @@ -38,12 +38,14 @@ Get the transaction by hash:
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
2. Transfer ETH and tokens on ZKsync Era
3. Withdraw ETH and tokens from ZKsync Era to Ethereum
4. Use paymaster to pay fee with token
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 [ZKsync Python guide](https://github.com/zksync-sdk/zksync2-examples/tree/main/python).
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.
2 changes: 1 addition & 1 deletion content/sdk/30.python/01.guides/01.features.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,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
14 changes: 7 additions & 7 deletions content/sdk/30.python/01.guides/02.accounts-l1-l2.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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/accounts)
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 @@ -15,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/accounts#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/accounts#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/accounts#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/accounts#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/accounts#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/accounts#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).
20 changes: 10 additions & 10 deletions content/sdk/30.python/02.api/00.providers/01.providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ zksync = ZkSyncBuilder.build("https://sepolia.era.zksync.dev")

### `zks_estimate_fee`

Returns an estimated [`Fee`](/sdk/python/types#fee) for requested transaction.
Returns an estimated [`Fee`](/sdk/python/api/types#fee) for requested transaction.

#### Inputs

| Parameter | Type | Description |
| ------------- | --------------------------------------- | -------------------- |
| `transaction` | [`Transaction`](/sdk/python/types#transaction) | Transaction request. |
| `transaction` | [`Transaction`](/sdk/python/api/types#transaction) | Transaction request. |

#### Example

Expand All @@ -62,7 +62,7 @@ Returns an estimate(`int`) of the amount of gas required to submit a transaction

| Parameter | Type | Description |
| ------------- |-----------------------------------------| -------------------- |
| `transaction` | [`Transaction`](/sdk/python/types#transaction) | Transaction request. |
| `transaction` | [`Transaction`](/sdk/python/api/types#transaction) | Transaction request. |

[web3.py implementation.](https://web3py.readthedocs.io/en/stable/web3.eth.html#web3.eth.Eth.estimate_gas)

Expand Down Expand Up @@ -110,7 +110,7 @@ to get the transfer transaction and sends it to the `eth_estimate_gas` method.

| Parameter | Type | Description |
| ------------- | --------------------------------------- | ------------------------- |
| `transaction` | [`Transaction`](/sdk/python/types#transaction) | Transaction. |
| `transaction` | [`Transaction`](/sdk/python/api/types#transaction) | Transaction. |
| `token` | Address string | Token address (optional). |

#### Example
Expand All @@ -134,7 +134,7 @@ Returns gas estimation for an L1 to L2 execute operation.

| Parameter | Type |
| ------------- | --------------------------------------- |
| `Transaction` | [`Transaction`](/sdk/python/types#transaction) |
| `Transaction` | [`Transaction`](/sdk/python/api/types#transaction) |

#### Example

Expand Down Expand Up @@ -211,7 +211,7 @@ if __name__ == "__main__":

### `zks_get_block_details`

Returns [`BlockDetails`](/sdk/python/types#blockdetails) additional ZKsync-specific information about the L2 block.
Returns [`BlockDetails`](/sdk/python/api/types#blockdetails) additional ZKsync-specific information about the L2 block.

Calls the [`zks_getBlockDetails`](https://docs.zksync.io/build/api-reference/zks-rpc#zks_getblockdetailss) JSON-RPC method.

Expand Down Expand Up @@ -276,7 +276,7 @@ if __name__ == "__main__":

### `getContractAccountInfo`

Returns [`ContractAccountInfo`](/sdk/python/types#contractaccountinfo) class with version of the supported account
Returns [`ContractAccountInfo`](/sdk/python/api/types#contractaccountinfo) class with version of the supported account
abstraction and nonce ordering from a given contract address.

#### Inputs
Expand All @@ -295,7 +295,7 @@ result = zksync_web3.zksync.get_contract_account_info(contract_address)

### `zks_get_bridge_contracts`

Returns [`BridgeAddresses`](/sdk/python/types#bridgeaddresses) class containing addresses of the default ZKsync Era
Returns [`BridgeAddresses`](/sdk/python/api/types#bridgeaddresses) class containing addresses of the default ZKsync Era
bridge contracts on both L1 and L2.

```python
Expand Down Expand Up @@ -477,7 +477,7 @@ Returns the populated transfer transaction.

| Name | Description |
| ---------- |------------------------------------------------------|
| transaction | [`TransferTransaction`](/sdk/python/types#withdrawtransaction) |
| transaction | [`TransferTransaction`](/sdk/python/api/types#withdrawtransaction) |
| `from` | From address. |

#### Examples
Expand Down Expand Up @@ -515,7 +515,7 @@ Returns the populated withdrawal transaction.

| Name | Description |
| ---------- |------------------------------------------------------|
| transaction | [`WithdrawTransaction`](/sdk/python/types#withdrawtransaction) |
| transaction | [`WithdrawTransaction`](/sdk/python/api/types#withdrawtransaction) |
| `from` | From address. |

#### Examples
Expand Down
55 changes: 31 additions & 24 deletions content/sdk/30.python/02.api/01.accounts/00.introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ description: Overview of account functionalities in the ZKsync Python SDK.
tags: ["web3", "blockchain", "zksync", "accounts"]
---

The ZKsync Python SDK offers a comprehensive suite of tools to manage accounts and perform various operations on the
ZKsync network. This includes creating wallets, signing transactions, verifying signatures, and interacting with smart contracts.
The ZKsync Python SDK has a method that generates a signature and a method that verifies messages.

::callout{icon="i-heroicons-light-bulb"}
For constructing the instance it needs only `account` and `chain_id`.
::

### Key Features

Expand All @@ -27,41 +30,45 @@ ZKsync network. This includes creating wallets, signing transactions, verifying
- Method to verify the signed EIP712-typed ZKsync transactions, ensuring that the transactions are authentic and
have not been tampered with.

### Example Usage

Creating a wallet from a private key and interacting with the ZKsync network:
#### Example

```python
from zksync2.signer.eth_signer import PrivateKeyEthSigner
from eth_account import Account
from zksync2.module.module_builder import ZkSyncBuilder


account = Account.from_key("PRIVATE_KEY")
zksync_web3 = ZkSyncBuilder.build("ZKSYNC_NETWORK_URL")

chain_id = zksync_web3.zksync.chain_id
signer = PrivateKeyEthSigner(account, chain_id)

```

Signing a typed data transaction:
### sign_typed_data

```python
from zksync2.core.types import TxFunctionCall

func_call = TxFunctionCall(
chain_id=chain_id,
nonce=nonce,
from_=account.address,
to=saccount.address,
gas_limit=0,
gas_price=gas_price,
)
signed_message = signer.sign_typed_data(func_call.tx)
```
The signer is used to generate the signature of the provided transaction based on your account(your private key).

Verifying a signed transaction:
#### Parameters

```python
is_valid = signer.verify_typed_data(signed_message, func_call.tx)
print("Signature valid:", is_valid)
```
| Parameters | Return value | Description |
| --------------------------------- | --------------------- | --------------------------------------------------------------------------- |
| EIP712 Structure, optional domain | Web3 py SignedMessage | Builds `SignedMessage` based on the encoded in `EIP712` format Transaction. |

### verify_typed_data

It's used to verify the provided transaction, whose signature is added to the final `EIP712` transaction for its validation.

#### Parameters

| Parameters | Return value | Description |
| -------------------------------------------- | ------------ | ------------------------------------------------------------------------------ |
| signature, EIP712 structure, optional domain | bool | Returns **True** if the encoded transaction is signed with provided signature. |

The signer class also has the following properties:

| Attribute | Description |
| --------- | ------------------------------------------------------------------------------- |
| address | Account address |
| domain | Domain that is used to generate signature. It depends on `chain_id` of network. |
Loading

0 comments on commit 0499e05

Please sign in to comment.