Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Commit

Permalink
docs: fix/sdk update examples (#822)
Browse files Browse the repository at this point in the history
  • Loading branch information
danijelTxFusion authored Dec 12, 2023
1 parent 3264eaf commit be9eeef
Show file tree
Hide file tree
Showing 38 changed files with 198 additions and 211 deletions.
6 changes: 3 additions & 3 deletions docs/api/go/examples/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
func main() {
var (
PrivateKey = os.Getenv("PRIVATE_KEY")
ZkSyncEraProvider = "https://testnet.era.zksync.dev"
ZkSyncEraProvider = "https://sepolia.era.zksync.dev"
)

// Connect to zkSync network
Expand Down Expand Up @@ -181,7 +181,7 @@ import (
func main() {
var (
PrivateKey = os.Getenv("PRIVATE_KEY")
ZkSyncEraProvider = "https://testnet.era.zksync.dev"
ZkSyncEraProvider = "https://sepolia.era.zksync.dev"
)

// Connect to zkSync network
Expand Down Expand Up @@ -302,7 +302,7 @@ import (
func main() {
var (
PrivateKey = os.Getenv("PRIVATE_KEY")
ZkSyncEraProvider = "https://testnet.era.zksync.dev"
ZkSyncEraProvider = "https://sepolia.era.zksync.dev"
)

// Connect to zkSync network
Expand Down
6 changes: 3 additions & 3 deletions docs/api/go/examples/create2.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
func main() {
var (
PrivateKey = os.Getenv("PRIVATE_KEY")
ZkSyncEraProvider = "https://testnet.era.zksync.dev"
ZkSyncEraProvider = "https://sepolia.era.zksync.dev"
)

// Connect to zkSync network
Expand Down Expand Up @@ -154,7 +154,7 @@ import (
func main() {
var (
PrivateKey = os.Getenv("PRIVATE_KEY")
ZkSyncEraProvider = "https://testnet.era.zksync.dev"
ZkSyncEraProvider = "https://sepolia.era.zksync.dev"
)

// Connect to zkSync network
Expand Down Expand Up @@ -288,7 +288,7 @@ import (
func main() {
var (
PrivateKey = os.Getenv("PRIVATE_KEY")
ZkSyncEraProvider = "https://testnet.era.zksync.dev"
ZkSyncEraProvider = "https://sepolia.era.zksync.dev"
)

// Connect to zkSync network
Expand Down
8 changes: 4 additions & 4 deletions docs/api/go/examples/custom-paymaster/deploy-account.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ head:
# Deploy paymaster

Deploy the paymaster account, which will receive the token deployed in the [previous](deploy-token.md) step and pay the fee in ETH for the account that
sends the token. The token address on testnet that is deployed in previous step is `0xCd9BDa1d0FC539043D4C80103bdF4f9cb108931B`
sends the token. The token address on testnet that is deployed in previous step is `0x765F5AF819D818a8e8ee6ff63D8d0e8056DBE150`

## Deploy paymaster with CREATE opcode

Expand All @@ -29,8 +29,8 @@ import (
func main() {
var (
PrivateKey = os.Getenv("PRIVATE_KEY")
ZkSyncEraProvider = "https://testnet.era.zksync.dev"
TokenAddress = "0xCd9BDa1d0FC539043D4C80103bdF4f9cb108931B" // Crown token which can be minted for free
ZkSyncEraProvider = "https://sepolia.era.zksync.dev"
TokenAddress = "0x765F5AF819D818a8e8ee6ff63D8d0e8056DBE150" // Crown token which can be minted for free
)

// Connect to zkSync network
Expand Down Expand Up @@ -101,7 +101,7 @@ import (
func main() {
var (
PrivateKey = os.Getenv("PRIVATE_KEY")
ZkSyncEraProvider = "https://testnet.era.zksync.dev"
ZkSyncEraProvider = "https://sepolia.era.zksync.dev"
TokenAddress = "0xCd9BDa1d0FC539043D4C80103bdF4f9cb108931B" // Crown token which can be minted for free
)

Expand Down
4 changes: 2 additions & 2 deletions docs/api/go/examples/custom-paymaster/deploy-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
func main() {
var (
PrivateKey = os.Getenv("PRIVATE_KEY")
ZkSyncEraProvider = "https://testnet.era.zksync.dev"
ZkSyncEraProvider = "https://sepolia.era.zksync.dev"
)

// Connect to zkSync network
Expand Down Expand Up @@ -121,7 +121,7 @@ import (
func main() {
var (
PrivateKey = os.Getenv("PRIVATE_KEY")
ZkSyncEraProvider = "https://testnet.era.zksync.dev"
ZkSyncEraProvider = "https://sepolia.era.zksync.dev"
)

// Connect to zkSync network
Expand Down
10 changes: 5 additions & 5 deletions docs/api/go/examples/custom-paymaster/use-paymaster.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ This example demonstrates how to use a paymaster to facilitate fee payment with
The user initiates a mint transaction that is configured to be paid with an ERC20 token through the paymaster.
During transaction execution, the paymaster receives the ERC20 token from the user and covers the transaction fee using ETH.

The token address used in this example is already [deployed](deploy-token.md) at: `0xCd9BDa1d0FC539043D4C80103bdF4f9cb108931B`.
The paymaster address used in this example is already [deployed](deploy-account.md) at: `0xd660c2F92d3d0634e5A20f26821C43F1b09298fe`.
The token address used in this example is already [deployed](deploy-token.md) at: `0x765F5AF819D818a8e8ee6ff63D8d0e8056DBE150`.
The paymaster address used in this example is already [deployed](deploy-account.md) at: `0x3cb2b87d10ac01736a65688f3e0fb1b070b3eea3`.

```go
package main
Expand All @@ -35,9 +35,9 @@ import (
func main() {
var (
PrivateKey = os.Getenv("PRIVATE_KEY")
ZkSyncEraProvider = "https://testnet.era.zksync.dev"
TokenAddress = common.HexToAddress("0xCd9BDa1d0FC539043D4C80103bdF4f9cb108931B") // Crown token which can be minted for free
PaymasterAddress = common.HexToAddress("0xd660c2F92d3d0634e5A20f26821C43F1b09298fe") // Paymaster for Crown token
ZkSyncEraProvider = "https://sepolia.era.zksync.dev"
TokenAddress = common.HexToAddress("0x765F5AF819D818a8e8ee6ff63D8d0e8056DBE150") // Crown token which can be minted for free
PaymasterAddress = common.HexToAddress("0x3cb2b87d10ac01736a65688f3e0fb1b070b3eea3") // Paymaster for Crown token
)

// Connect to zkSync network
Expand Down
11 changes: 5 additions & 6 deletions docs/api/go/examples/deposit.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
func main() {
var (
PrivateKey = os.Getenv("PRIVATE_KEY")
ZkSyncEraProvider = "https://testnet.era.zksync.dev"
EthereumProvider = "https://rpc.ankr.com/eth_goerli"
ZkSyncEraProvider = "https://sepolia.era.zksync.dev"
EthereumProvider = "https://rpc.ankr.com/eth_sepolia"
)

// Connect to zkSync network
Expand Down Expand Up @@ -135,7 +135,7 @@ func main() {
PrivateKey = os.Getenv("PRIVATE_KEY")
ZkSyncEraProvider = "https://testnet.era.zksync.dev"
EthereumProvider = "https://rpc.ankr.com/eth_goerli"
TokenL1Address = common.HexToAddress("0xc8F8cE6491227a6a2Ab92e67a64011a4Eba1C6CF")
TokenL1Address = common.HexToAddress("0x56E69Fa1BB0d1402c89E3A4E3417882DeA6B14Be")
)

// Connect to zkSync network
Expand Down Expand Up @@ -243,7 +243,6 @@ func main() {

fmt.Println("Token balance on L2 network: ", tokenL2Balance)
}

```

## Claim failed deposit
Expand All @@ -266,8 +265,8 @@ import (
func main() {
var (
PrivateKey = os.Getenv("PRIVATE_KEY")
ZkSyncEraProvider = "https://testnet.era.zksync.dev"
EthereumProvider = "https://rpc.ankr.com/eth_goerli"
ZkSyncEraProvider = "https://sepolia.era.zksync.dev"
EthereumProvider = "https://rpc.ankr.com/eth_sepolia"
DepositL2Tx = common.HexToHash("<Failed Deposit L2 tx hash>")
)

Expand Down
2 changes: 1 addition & 1 deletion docs/api/go/examples/get-confirmed-tokens.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

func main() {
var (
ZkSyncEraProvider = "https://testnet.era.zksync.dev"
ZkSyncEraProvider = "https://sepolia.era.zksync.dev"
)

client, err := clients.Dial(ZkSyncEraProvider)
Expand Down
9 changes: 4 additions & 5 deletions docs/api/go/examples/transfer.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
func main() {
var (
PrivateKey1 = os.Getenv("PRIVATE_KEY")
PublicKey2 = "81E9D85b65E9CC8618D85A1110e4b1DF63fA30d9"
ZkSyncEraProvider = "https://testnet.era.zksync.dev"
PublicKey2 = "0x81E9D85b65E9CC8618D85A1110e4b1DF63fA30d9"
ZkSyncEraProvider = "https://sepolia.era.zksync.dev"
)

// Connect to zkSync network
Expand Down Expand Up @@ -112,8 +112,8 @@ func main() {
var (
PrivateKey1 = os.Getenv("PRIVATE_KEY")
PublicKey2 = "0x81E9D85b65E9CC8618D85A1110e4b1DF63fA30d9"
ZkSyncEraProvider = "https://testnet.era.zksync.dev"
TokenL2Address = common.HexToAddress("0xCd9BDa1d0FC539043D4C80103bdF4f9cb108931B")
ZkSyncEraProvider = "https://sepolia.era.zksync.dev"
TokenL2Address = common.HexToAddress("0x6a4Fb925583F7D4dF82de62d98107468aE846FD1")
)

// Connect to zkSync network
Expand Down Expand Up @@ -177,5 +177,4 @@ func main() {
fmt.Println("Account 2 token balance after transfer: ", account2TokenBalance)

}

```
39 changes: 12 additions & 27 deletions docs/api/go/examples/withdraw.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ This is an example of how to withdraw ETH from zkSync Era network (L2) to Ethere
package main

import (
"context"
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
Expand All @@ -40,8 +39,8 @@ import (
func main() {
var (
PrivateKey = os.Getenv("PRIVATE_KEY")
ZkSyncEraProvider = "https://testnet.era.zksync.dev"
EthereumProvider = "https://rpc.ankr.com/eth_goerli"
ZkSyncEraProvider = "https://sepolia.era.zksync.dev"
EthereumProvider = "https://rpc.ankr.com/eth_sepolia"
)

// Connect to zkSync network
Expand All @@ -61,7 +60,7 @@ func main() {
// Create wallet
wallet, err := accounts.NewWallet(common.Hex2Bytes(PrivateKey), &client, ethClient)
if err != nil {
log.Fatal(err)
log.Panic(err)
}

// Perform withdrawal
Expand All @@ -70,23 +69,10 @@ func main() {
Amount: big.NewInt(1_000_000_000),
Token: utils.EthAddress,
})
if err != nil {
panic(err)
}
fmt.Println("Withdraw transaction: ", tx.Hash())

// Wait until transaction is finalized
_, err = client.WaitFinalized(context.Background(), tx.Hash())
if err != nil {
log.Panic(err)
}

// Perform finalize withdrawal
finalizeWithdrawTx, err := wallet.FinalizeWithdraw(nil, tx.Hash(), 0)
if err != nil {
log.Panic(err)
}
fmt.Println("Finalize withdraw transaction: ", finalizeWithdrawTx.Hash())
fmt.Println("Withdraw transaction: ", tx.Hash())
}
```

Expand All @@ -103,7 +89,6 @@ import (
"github.com/ethereum/go-ethereum/ethclient"
"github.com/zksync-sdk/zksync2-go/accounts"
"github.com/zksync-sdk/zksync2-go/clients"
"github.com/zksync-sdk/zksync2-go/utils"
"log"
"math/big"
"os"
Expand All @@ -112,8 +97,9 @@ import (
func main() {
var (
PrivateKey = os.Getenv("PRIVATE_KEY")
ZkSyncEraProvider = "https://testnet.era.zksync.dev"
EthereumProvider = "https://rpc.ankr.com/eth_goerli"
ZkSyncEraProvider = "https://sepolia.era.zksync.dev"
EthereumProvider = "https://rpc.ankr.com/eth_sepolia"
TokenL2Address = common.HexToAddress("0x6a4Fb925583F7D4dF82de62d98107468aE846FD1")
)

// Connect to zkSync network
Expand All @@ -136,18 +122,17 @@ func main() {
log.Panic(err)
}

// Perform withdrawal
// Perform withdraw
tx, err := wallet.Withdraw(nil, accounts.WithdrawalTransaction{
To: wallet.Address(),
Amount: big.NewInt(1_000_000_000),
Token: utils.EthAddress,
Amount: big.NewInt(1),
Token: TokenL2Address,
})
if err != nil {
log.Panic(err)
}
fmt.Println("Withdraw transaction: ", tx.Hash())
}

```

## Finalize withdrawal
Expand All @@ -170,8 +155,8 @@ import (
func main() {
var (
PrivateKey = os.Getenv("PRIVATE_KEY")
ZkSyncEraProvider = "https://testnet.era.zksync.dev"
EthereumProvider = "https://rpc.ankr.com/eth_goerli"
ZkSyncEraProvider = "https://sepolia.era.zksync.dev"
EthereumProvider = "https://rpc.ankr.com/eth_sepolia"
WithdrawTx = common.HexToHash("<Withdraw tx hash>")
)

Expand Down
4 changes: 2 additions & 2 deletions docs/api/js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ head:
content: JS SDK | zkSync Era Docs
---

# JavaScript Web3 SDK
# JavaScript Era SDK

While most of the existing SDKs should work out of the box, deploying smart contracts or using unique zkSync features, like paying fees in other tokens, requires providing additional fields to those that Ethereum transactions have by default.

To provide easy access to all of the features of zkSync Era, the `zksync-web3` JavaScript SDK was created, which is based on the `ethers.js` library. This section serves as its reference.
To provide easy access to all the features of zkSync Era, the `zksync-ethers` JavaScript SDK was created, which is based on the `ethers.js` library. This section serves as its reference.

## Contents

Expand Down
6 changes: 3 additions & 3 deletions docs/api/js/accounts-l1-l2.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async approveERC20(
> Example
```typescript
import { Wallet, Provider } from "zksync-web3";
import { Wallet, Provider } from "zksync-ethers";
import { ethers } from "ethers";

const PRIVATE_KEY = "<WALLET_PRIVATE_KEY>";
Expand Down Expand Up @@ -92,7 +92,7 @@ async deposit(transaction: {
> Example
```typescript
import { Wallet, Provider, utils } from "zksync-web3";
import { Wallet, Provider, utils } from "zksync-ethers";
import { ethers } from "ethers";

const PRIVATE_KEY = "<WALLET_PRIVATE_KEY>";
Expand Down Expand Up @@ -211,7 +211,7 @@ async requestExecute(transaction: {
> Example
```typescript
import { Wallet, Provider } from "zksync-web3";
import { Wallet, Provider } from "zksync-ethers";
import { BigNumber, ethers } from "ethers";

const PRIVATE_KEY = "<WALLET_PRIVATE_KEY>";
Expand Down
2 changes: 1 addition & 1 deletion docs/api/js/accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ head:

# Accounts: overview

`zksync-web3` exports four classes that can sign transactions on zkSync:
`zksync-ethers` exports four classes that can sign transactions on zkSync:

- `Wallet` class is an extension of the `ethers.Wallet` with additional zkSync features.
- `EIP712Signer` class that is used to sign `EIP712`_-typed_ zkSync transactions.
Expand Down
2 changes: 1 addition & 1 deletion docs/api/js/contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ head:

# Contracts

`zksync-web3` does not implement any new `Contract` class, since `ethers.Contract` fully works out of the box. However, for convenience, the library still re-exports this class.
`zksync-ethers` does not implement any new `Contract` class, since `ethers.Contract` fully works out of the box. However, for convenience, the library still re-exports this class.

Since deploying smart contracts on zkSync has some differences from deploying on Ethereum, there is a need for a specific `ContractFactory` method. It supports the same interface as `ethers.ContractFactory`.

Expand Down
3 changes: 2 additions & 1 deletion docs/api/js/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ This document will focus solely on how to pass these arguments to the SDK.

In this case, you can provide an `Overrides` object as the last parameter. There you can supply fields like `gasPrice`, `gasLimit`, `nonce` etc.

In order to make the SDK as flexible as possible, `zksync-web3` uses `customData` object in the overrides to supply zkSync-specific fields. To supply zkSync-specific fields, you need to pass the following override:
In order to make the SDK as flexible as possible, `zksync-ethers` uses `customData` object in the overrides to supply zkSync-specific fields. To supply zkSync-specific fields, you
need to pass the following override:

```typescript
{
Expand Down
3 changes: 2 additions & 1 deletion docs/api/js/front-end.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ If your front-end code does not deploy new smart contracts, then no changes to t

## Enabling zkSync features

If you want to deploy smart contracts or enable advanced zkSync features, like account abstraction, then you need to use the `zksync-web3` library for that. You can read about the basics [here](./features.md).
If you want to deploy smart contracts or enable advanced zkSync features, like account abstraction, then you need to use the `zksync-ethers` library for that. You can read about
the basics [here](./features.md).

If you want to see some code, check out our basic [tutorial](../../dev/building-on-zksync/hello-world.md) for full mini-dApp.
Loading

0 comments on commit be9eeef

Please sign in to comment.