From 3927293f56ef2e30c0f0dd888499834737507be3 Mon Sep 17 00:00:00 2001 From: Ngozi-Txfusion Date: Wed, 3 Jul 2024 10:54:16 +0100 Subject: [PATCH] chore: update description --- .../05.api/10.v5/00.providers/01.provider.md | 9 +- .../10.v5/00.providers/02.web3provider.md | 327 +++++++++++++----- .../05.api/10.v5/01.accounts/01.wallet.md | 6 +- .../10.v5/01.accounts/04.eip712signer.md | 2 +- .../04.utilities/02.smart-account-utils.md | 2 + .../10.js/00.ethers/05.api/10.v5/05.types.md | 3 + .../05.api/20.v6/00.providers/01.provider.md | 5 +- .../20.v6/00.providers/02.browser-provider.md | 159 ++++++++- .../05.api/20.v6/01.accounts/01.wallet.md | 2 + .../20.v6/01.accounts/04.eip712signer.md | 3 +- .../04.utilities/02.smart-account-utils.md | 2 + .../10.js/00.ethers/05.api/20.v6/05.types.md | 3 + 12 files changed, 420 insertions(+), 103 deletions(-) diff --git a/content/sdk/10.js/00.ethers/05.api/10.v5/00.providers/01.provider.md b/content/sdk/10.js/00.ethers/05.api/10.v5/00.providers/01.provider.md index cb0313ea..f4c3e10b 100644 --- a/content/sdk/10.js/00.ethers/05.api/10.v5/00.providers/01.provider.md +++ b/content/sdk/10.js/00.ethers/05.api/10.v5/00.providers/01.provider.md @@ -1,13 +1,14 @@ --- title: Provider -description: Provider objects for integrating with ZKsync. +description: Provider objects for interacting with ZKsync. tags: ["zksync", "providers", "integration"] --- - +Provider objects facilitate interaction with the ZKsync network, allowing users to manage transactions, estimate fees, +and retrieve network information. ### `constructor` -Returns a ZKsync Era `Provider` object. +Initializes a ZKsync Era `Provider` object. #### Inputs @@ -571,7 +572,7 @@ Returns true if passed bridge address is legacy and false if its shared bridge. async isL2BridgeLegacy(address: Address): Promise ``` -### Example +#### Example ```ts import { Provider, types } from "zksync-ethers"; diff --git a/content/sdk/10.js/00.ethers/05.api/10.v5/00.providers/02.web3provider.md b/content/sdk/10.js/00.ethers/05.api/10.v5/00.providers/02.web3provider.md index fc01df5c..3f492d5e 100644 --- a/content/sdk/10.js/00.ethers/05.api/10.v5/00.providers/02.web3provider.md +++ b/content/sdk/10.js/00.ethers/05.api/10.v5/00.providers/02.web3provider.md @@ -1,6 +1,6 @@ --- title: Web3Provider -description: Web3Provider objects for integrating with ZKsync. +description: Web3Provider objects for interacting with ZKsync. tags: ["zksync", "web3", "providers", "integration"] --- @@ -9,13 +9,19 @@ integration with browser wallets (e.g., MetaMask, WalletConnect). It supports RP ## `Constructor` +Initializes a new instance of the `Web3Provider` class. + +#### Inputs + +| Parameter | Type | Description | +|------------|-----------------------------------------------------------|----------------------------------------------------| +| `provider` | `ExternalProvider` | The provider injected from the browser (e.g., MetaMask's `window.ethereum`). | +| `network?` | `ethers.providers.Networkish` | Optional. The network name, chain ID, or object with network details. | + ```typescript constructor(provider: ExternalProvider, network?: ethers.providers.Networkish) ``` -- **provider**: The provider injected from the browser. For instance, MetaMask is `window.ethereum`. -- **network**: Optional. The network name, chain ID, or object with network details. - #### Example ```typescript @@ -28,12 +34,18 @@ const provider = new Web3Provider(window.ethereum); ### `getTransactionReceipt` +Returns the transaction receipt for the specified `txHash`, if mined. + +#### Inputs + +| Parameter | Type | Description | +|-----------|----------|--------------------| +| `txHash` | `string` | The transaction hash. | + ```typescript override async getTransactionReceipt(txHash: string): Promise ``` -Returns the transaction receipt for the specified `txHash`, if mined. - #### Example ```typescript @@ -46,12 +58,18 @@ console.log(`Transaction receipt: ${utils.toJSON(await provider.getTransactionRe ### `getTransaction` +Returns the transaction for the specified `txHash`. + +#### Inputs + +| Parameter | Type | Description | +|-----------|----------|--------------------| +| `txHash` | `string` | The transaction hash. | + ```typescript override async getTransaction(txHash: string): Promise ``` -Returns the transaction for the specified `txHash`. - #### Example ```typescript @@ -69,12 +87,18 @@ await tx.waitFinalize(); ### `getBlock` +Returns the block for the specified `blockHashOrBlockTag`. + +#### Inputs + +| Parameter | Type | Description | +|----------------------|---------------------------------|-------------------------| +| `blockHashOrBlockTag`| `BlockTag` or `string` | The block hash or tag. | + ```typescript override async getBlock(blockHashOrBlockTag: BlockTag | string | Promise): Promise ``` -Returns the block for the specified `blockHashOrBlockTag`. - #### Example ```typescript @@ -86,12 +110,18 @@ console.log(`Block: ${utils.toJSON(await provider.getBlock("latest", true))}`); ### `getBlockWithTransactions` +Returns the block for the specified `blockHashOrBlockTag`, including all transactions. + +#### Inputs + +| Parameter | Type | Description | +|----------------------|---------------------------------|-------------------------| +| `blockHashOrBlockTag`| `BlockTag` or `string` | The block hash or tag. | + ```typescript override async getBlockWithTransactions(blockHashOrBlockTag: BlockTag | string | Promise): Promise ``` -Returns the block for the specified `blockHashOrBlockTag`, including all transactions. - #### Example ```typescript @@ -103,12 +133,18 @@ console.log(`Block: ${utils.toJSON(await provider.getBlockWithTransactions("late ### `getLogs` +Returns the list of logs that match the specified `filter`. + +#### Inputs + +| Parameter | Type | Description | +|-----------|-----------|--------------------| +| `filter` | `EventFilter` or `Promise` | The filter object. | + ```typescript override async getLogs(filter: EventFilter | Promise = {}): Promise> ``` -Returns the list of logs that match the specified `filter`. - #### Example ```typescript @@ -120,12 +156,20 @@ console.log(`Logs: ${utils.toJSON(await provider.getLogs({ fromBlock: 0, toBlock ### `getBalance` +Returns the account balance for the specified `address`, `blockTag`, and `tokenAddress`. + +#### Inputs + +| Parameter | Type | Description | +|-----------------|--------------|----------------------------------------------| +| `address` | `Address` | The account address. | +| `blockTag?` | `BlockTag` | Optional. The block tag for balance query. | +| `tokenAddress?` | `Address` | Optional. The token address. | + ```typescript override async getBalance(address: Address, blockTag?: BlockTag, tokenAddress?: Address): Promise ``` -Returns the account balance for the specified `address`, `blockTag`, and `tokenAddress`. - #### Example ```typescript @@ -140,12 +184,18 @@ console.log(`Token balance: ${await provider.getBalance(account, "latest", token ### `l2TokenAddress` +Returns the L2 token address equivalent for an L1 token address. + +#### Inputs + +| Parameter | Type | Description | +|-----------|-----------|----------------------------| +| `token` | `Address` | The address of the L1 token. | + ```typescript override async l2TokenAddress(token: Address): Promise ``` -Returns the L2 token address equivalent for a L1 token address. - #### Example ```typescript @@ -157,12 +207,18 @@ console.log(`L2 token address: ${await provider.l2TokenAddress("0x5C221E77624690 ### `l1TokenAddress` +Returns the L1 token address equivalent for an L2 token address. + +#### Inputs + +| Parameter | Type | Description | +|-----------|-----------|----------------------------| +| `token` | `Address` | The address of the L2 token. | + ```typescript override async l1TokenAddress(token: Address): Promise ``` -Returns the L1 token address equivalent for a L2 token address. - #### Example ```typescript @@ -174,12 +230,18 @@ console.log(`L1 token address: ${await provider.l1TokenAddress("0x3e7676937A7E96 ### `getProtocolVersion` +Returns the protocol version. + +#### Inputs + +| Parameter | Type | Description | +|-----------|----------|---------------------------| +| `id?` | `number` | Optional. Specific version ID. | + ```typescript override async getProtocolVersion(id?: number): Promise ``` -Returns the protocol version. - #### Example ```typescript @@ -191,12 +253,18 @@ console.log(`Protocol version: ${await provider.getProtocolVersion()}`); ### `estimateGasL1` +Estimates the amount of gas required to submit a transaction from L1 to L2. + +#### Inputs + +| Parameter | Type | Description | +|---------------|----------------------|-----------------------| +| `transaction` | `TransactionRequest` | The transaction request. | + ```typescript override async estimateGasL1(transaction: TransactionRequest): Promise ``` -Estimates the amount of gas required to submit a transaction from L1 to L2. - #### Example ```typescript @@ -216,12 +284,18 @@ console.log(`L1 gas: ${gasL1}`); ### `estimateFee` +Returns an estimated fee for the requested transaction. + +#### Inputs + +| Parameter | Type | Description | +|---------------|----------------------|-----------------------| +| `transaction` | `TransactionRequest` | The transaction request. | + ```typescript override async estimateFee(transaction: TransactionRequest): Promise ``` -Returns an estimated fee for the requested transaction. - #### Example ```typescript @@ -230,7 +304,9 @@ import { Web3Provider, utils } from "zksync-ethers"; const provider = new Web3Provider(window.ethereum); const fee = await provider.estimateFee({ from: "0x36615Cf349d7F6344891B1e7CA7C72883F5dc049", - to: "0xa61464658AfeAf65CccaaFD3a512b69A83B77618", + to: "0xa61464658AfeAf65CccaaFD3 + +a512b69A83B77618", value: BigNumber.from(7_000_000_000).toHexString(), }); console.log(`Fee: ${utils.toJSON(fee)}`); @@ -238,12 +314,12 @@ console.log(`Fee: ${utils.toJSON(fee)}`); ### `getFeeParams` +Returns the current fee parameters. + ```typescript override async getFeeParams(): Promise ``` -Returns the current fee parameters. - #### Example ```typescript @@ -256,12 +332,12 @@ console.log(`Fee: ${utils.toJSON(feeParams)}`); ### `getGasPrice` +Returns an estimate of the gas price to use in a transaction. + ```typescript override async getGasPrice(): Promise ``` -Returns an estimate of the gas price to use in a transaction. - #### Example ```typescript @@ -273,12 +349,19 @@ console.log(`Gas price: ${await provider.getGasPrice()}`); ### `getLogProof` +Returns the proof for a transaction's L2 to L1 log sent via the `L1Messenger` system contract. + +#### Inputs + +| Parameter | Type | Description | +|-----------|-------------|----------------------------------------------| +| `txHash` | `BytesLike` | Hash of the L2 transaction. | +| `index?` | `number` | Optional. Index of the L2 to L1 log in the transaction. | + ```typescript override async getLogProof(txHash: BytesLike, index?: number): Promise ``` -Returns the proof for a transaction's L2 to L1 log sent via the `L1Messenger` system contract. - #### Example ```typescript @@ -293,12 +376,18 @@ console.log(`Log ${utils.toJSON(await provider.getLogProof(tx, 0))}`); ### `getL1BatchBlockRange` +Returns the range of blocks contained within a batch given by batch number. + +#### Inputs + +| Parameter | Type | Description | +|-----------------|----------|------------------| +| `l1BatchNumber` | `number` | The L1 batch number. | + ```typescript override async getL1BatchBlockRange(l1BatchNumber: number): Promise<[number, number] | null> ``` -Returns the range of blocks contained within a batch given by batch number. - #### Example ```typescript @@ -311,31 +400,29 @@ console.log(`L1 batch block range: ${utils.toJSON(await provider.getL1BatchBlock ### `getBridgehubContractAddress` +Returns the Bridgehub smart contract address. + ```typescript override async getBridgehubContractAddress(): Promise
``` -Returns the Bridgehub smart contract address. - #### Example ```typescript import { Web3Provider } from "zksync-ethers"; const provider = new Web3Provider(window.ethereum); -console.log(`Bridgehub: ${await provider.getBridgehubContractAddress() - -}`); +console.log(`Bridgehub: ${await provider.getBridgehubContractAddress()}`); ``` ### `getBaseTokenContractAddress` +Returns the L1 base token address. + ```typescript override async getBaseTokenContractAddress(): Promise
``` -Returns the L1 base token address. - #### Example ```typescript @@ -347,12 +434,12 @@ console.log(`Base token: ${await provider.getBaseTokenContractAddress()}`); ### `isEthBasedChain` +Returns whether the chain is ETH-based. + ```typescript override async isEthBasedChain(): Promise ``` -Returns whether the chain is ETH-based. - #### Example ```typescript @@ -364,12 +451,18 @@ console.log(`Is ETH based chain: ${await provider.isEthBasedChain()}`); ### `isBaseToken` +Returns whether the `token` is the base token. + +#### Inputs + +| Parameter | Type | Description | +|-----------|-----------|----------------------------| +| `token` | `Address` | The address of the token. | + ```typescript override async isBaseToken(token: Address): Promise ``` -Returns whether the `token` is the base token. - #### Example ```typescript @@ -381,12 +474,12 @@ console.log(`Is base token: ${await provider.isBaseToken("0x5C221E77624690fff6dd ### `getMainContractAddress` +Returns the main ZKsync Era smart contract address. + ```typescript override async getMainContractAddress(): Promise
``` -Returns the main ZKsync Era smart contract address. - #### Example ```typescript @@ -398,12 +491,12 @@ console.log(`Main contract: ${await provider.getMainContractAddress()}`); ### `getTestnetPaymasterAddress` +Returns the testnet paymaster address, if available. + ```typescript override async getTestnetPaymasterAddress(): Promise
``` -Returns the testnet paymaster address, if available. - #### Example ```typescript @@ -415,12 +508,12 @@ console.log(`Testnet paymaster: ${await provider.getTestnetPaymasterAddress()}`) ### `getDefaultBridgeAddresses` +Returns the addresses of the default ZKsync Era bridge contracts on both L1 and L2. + ```typescript override async getDefaultBridgeAddresses(): Promise<{ erc20L1: string; erc20L2: string; wethL1: string; wethL2: string; sharedL1: string; sharedL2: string; }> ``` -Returns the addresses of the default ZKsync Era bridge contracts on both L1 and L2. - #### Example ```typescript @@ -432,12 +525,18 @@ console.log(`Bridge addresses: ${await provider.getDefaultBridgeAddresses()}`); ### `getAllAccountBalances` +Returns all balances for confirmed tokens given by an account address. + +#### Inputs + +| Parameter | Type | Description | +|-----------|-----------|---------------------------| +| `address` | `Address` | The account address. | + ```typescript override async getAllAccountBalances(address: Address): Promise ``` -Returns all balances for confirmed tokens given by an account address. - #### Example ```typescript @@ -450,12 +549,19 @@ console.log(`All balances: ${utils.toJSON(balances)}`); ### `getConfirmedTokens` +Returns confirmed tokens. Confirmed token is any token bridged to ZKsync Era via the official bridge. + +#### Inputs + +| Parameter | Type | Description | +|-----------|---------|-------------------------------| +| `start?` | `number`| Optional. The token ID from which to start. Default is 0. | +| `limit?` | `number`| Optional. The maximum number of tokens to list. Default is 255. | + ```typescript override async getConfirmedTokens(start?: number, limit?: number): Promise ``` -Returns confirmed tokens. Confirmed token is any token bridged to ZKsync Era via the official bridge. - #### Example ```typescript @@ -468,30 +574,29 @@ console.log(`Confirmed tokens: ${utils.toJSON(tokens)}`); ### `l1ChainId` +Returns the L1 chain ID. + ```typescript override async l1ChainId(): Promise ``` -Returns the L1 chain ID. - #### Example ```typescript import { Web3Provider } from "zksync-ethers"; const provider = new Web3Provider(window.ethereum); -const l1ChainId = await provider.l1ChainId(); -console.log(`All balances: ${l1ChainId}`); +console.log(`L1 chain ID: ${await provider.l1ChainId()}`); ``` ### `getL1BatchNumber` +Returns the latest L1 batch number. + ```typescript override async getL1BatchNumber(): Promise ``` -Returns the latest L1 batch number. - #### Example ```typescript @@ -503,12 +608,18 @@ console.log(`L1 batch number: ${await provider.getL1BatchNumber()}`); ### `getL1BatchDetails` +Returns data pertaining to a given batch. + +#### Inputs + +| Parameter | Type | Description | +|-----------|---------|------------------------| +| `number` | `number`| The L1 batch number. | + ```typescript override async getL1BatchDetails(number: number): Promise ``` -Returns data pertaining to a given batch. - #### Example ```typescript @@ -521,29 +632,43 @@ console.log(`L1 batch details: ${utils.toJSON(await provider.getL1BatchDetails(l ### `getBlockDetails` +Returns additional ZKsync-specific information about the L2 block. + +#### Inputs + +| Parameter | Type | Description | +|-----------|---------|-----------------------| +| `number` | `number`| The block number. | + ```typescript override async getBlockDetails(number: number): Promise ``` -Returns additional ZKsync-specific information about the L2 block. - #### Example ```typescript import { Web3Provider, utils } from "zksync-ethers"; -const provider = new Web3Provider(window.ethereum); +const provider = new Web3 + +Provider(window.ethereum); console.log(`Block details: ${utils.toJSON(await provider.getBlockDetails(90_000))}`); ``` ### `getTransactionDetails` +Returns data from a specific transaction given by the transaction hash. + +#### Inputs + +| Parameter | Type | Description | +|-----------|-------------|--------------------| +| `txHash` | `BytesLike` | The transaction hash. | + ```typescript override async getTransactionDetails(txHash: BytesLike): Promise ``` -Returns data from a specific transaction given by the transaction hash. - #### Example ```typescript @@ -556,12 +681,18 @@ console.log(`Transaction details: ${utils.toJSON(await provider.getTransactionDe ### `getBytecodeByHash` +Returns bytecode of a contract given by its hash. + +#### Inputs + +| Parameter | Type | Description | +|----------------|-------------|--------------------| +| `bytecodeHash` | `BytesLike` | The bytecode hash. | + ```typescript override async getBytecodeByHash(bytecodeHash: BytesLike): Promise ``` -Returns bytecode of a contract given by its hash. - #### Example ```typescript @@ -579,12 +710,18 @@ console.log(`Bytecode: ${await provider.getBytecodeByHash(testnetPaymasterByteco ### `getRawBlockTransactions` +Returns data of transactions in a block. + +#### Inputs + +| Parameter | Type | Description | +|-----------|---------|-------------------| +| `number` | `number`| The block number. | + ```typescript override async getRawBlockTransactions(number: number): Promise ``` -Returns data of transactions in a block. - #### Example ```typescript @@ -596,12 +733,20 @@ console.log(`Raw block transactions: ${utils.toJSON(await provider.getRawBlockTr ### `getProof` +Returns Merkle proofs for one or more storage values at the specified account along with a Merkle proof of their authenticity. + +#### Inputs + +| Parameter | Type | Description | +|-----------------|--------------|----------------------------------------------| +| `address` | `Address` | The account to fetch storage values and proofs for. | +| `keys` | `string[]` | Vector of storage keys in the account. | +| `l1BatchNumber` | `number` | The L1 batch number. | + ```typescript override async getProof(address: Address, keys: string[], l1BatchNumber: number): Promise ``` -Returns Merkle proofs for one or more storage values at the specified account along with a Merkle proof of their authenticity. - #### Example ```typescript @@ -633,13 +778,19 @@ console.log(`Storage proof: ${utils.toJSON(storageProof)}`); ### `sendRawTransactionWithDetailedOutput` +Executes a transaction and returns its hash, storage logs, and events that would have been generated if the +transaction had already been included in the block. + +#### Inputs + +| Parameter | Type | Description | +|------------|----------|------------------------------------------------------| +| `signedTx` | `string` | The signed transaction that needs to be broadcasted. | + ```typescript override async sendRawTransactionWithDetailedOutput(signedTx: string): Promise ``` -Executes a transaction and returns its hash, storage logs, and events that would have been generated if the -transaction had already been included in the block. - #### Example ```typescript @@ -652,9 +803,7 @@ const signer = Signer.from( Provider.getDefaultProvider(types.Network.Sepolia) ); -const txWithOutputs = await provider.send - -RawTransactionWithDetailedOutput( +const txWithOutputs = await provider.sendRawTransactionWithDetailedOutput( await signer.signTransaction({ to: "0x0330808583C22F812DD9B647Ed9F0411f44A1e6f", value: 7_000_000_000, @@ -666,15 +815,21 @@ RawTransactionWithDetailedOutput( console.log(`Transaction: ${utils.toJSON(txWithOutputs)}`); ``` -## `getSigner` +### `getSigner` + +Returns a `JsonRpcSigner` instance for the specified `addressOrIndex`. This is used to sign transactions and +messages using the connected wallet. + +#### Inputs + +| Parameter | Type | Description | +|------------------|-----------------------|----------------------------------| +| `addressOrIndex?`| `string` or `number` | Optional. The address or index. | ```typescript getSigner(addressOrIndex?: string | number): JsonRpcSigner ``` -Returns a `JsonRpcSigner` instance for the specified `addressOrIndex`. This is used to sign transactions and messages -using the connected wallet. - #### Example ```typescript @@ -691,6 +846,8 @@ console.log(`Signature: ${signature}`); ### toJSON +Helper function to convert objects to JSON string with BigInt support. + ```ts function toJSON(object: any): string { return JSON.stringify(object, (key, value) => { diff --git a/content/sdk/10.js/00.ethers/05.api/10.v5/01.accounts/01.wallet.md b/content/sdk/10.js/00.ethers/05.api/10.v5/01.accounts/01.wallet.md index 9c9b0015..bc8498b6 100644 --- a/content/sdk/10.js/00.ethers/05.api/10.v5/01.accounts/01.wallet.md +++ b/content/sdk/10.js/00.ethers/05.api/10.v5/01.accounts/01.wallet.md @@ -4,7 +4,11 @@ description: Wallet integration, creation, and management in ZKsync. tags: ["zksync", "wallet", "integration", "creation", "management"] --- -### `constructor` +The Wallet module provides functionalities for integrating, creating, and managing wallets within the ZKsync ecosystem. + +### `Constructor` + +The constructor initializes a wallet instance using a private key, and optionally connects it to L1 and L2 providers. #### Inputs diff --git a/content/sdk/10.js/00.ethers/05.api/10.v5/01.accounts/04.eip712signer.md b/content/sdk/10.js/00.ethers/05.api/10.v5/01.accounts/04.eip712signer.md index 567d5c34..41617316 100644 --- a/content/sdk/10.js/00.ethers/05.api/10.v5/01.accounts/04.eip712signer.md +++ b/content/sdk/10.js/00.ethers/05.api/10.v5/01.accounts/04.eip712signer.md @@ -4,7 +4,7 @@ description: EIP712Signer with ZKsync and ethers.js tags: ["zksync", "ethers.js", "blockchain", "EIP712", "smart contracts"] --- -Provides support for an EIP712 transaction. The methods of this class are mostly used internally. +This class provides support for an EIP712 transaction. The methods of this class are mostly used internally. ### `getSignInput` diff --git a/content/sdk/10.js/00.ethers/05.api/10.v5/04.utilities/02.smart-account-utils.md b/content/sdk/10.js/00.ethers/05.api/10.v5/04.utilities/02.smart-account-utils.md index d7526a72..bb6a09ca 100644 --- a/content/sdk/10.js/00.ethers/05.api/10.v5/04.utilities/02.smart-account-utils.md +++ b/content/sdk/10.js/00.ethers/05.api/10.v5/04.utilities/02.smart-account-utils.md @@ -4,6 +4,8 @@ description: Utilities for signing transactions with ECDSA private keys. tags: ["zksync", "ecdsa", "smart contracts", "ethereum", "transaction signing"] --- +This module provides utilities for signing transactions with ECDSA private keys in the ZKsync ecosystem. + ## Functions ### `signPayloadWithECDSA` diff --git a/content/sdk/10.js/00.ethers/05.api/10.v5/05.types.md b/content/sdk/10.js/00.ethers/05.api/10.v5/05.types.md index 8107ddd2..411d78f5 100644 --- a/content/sdk/10.js/00.ethers/05.api/10.v5/05.types.md +++ b/content/sdk/10.js/00.ethers/05.api/10.v5/05.types.md @@ -4,6 +4,9 @@ description: Definitions and interfaces used in ZKsync Era. tags: ["zksync", "types", "interfaces", "ethereum", "blockchain"] --- +These types and interfaces are essential for developers working with the ZKsync blockchain, as they define the +structures and enumerations for different components of the system. + ## `AccountAbstractionVersion` Enumerated list of account abstraction versions. diff --git a/content/sdk/10.js/00.ethers/05.api/20.v6/00.providers/01.provider.md b/content/sdk/10.js/00.ethers/05.api/20.v6/00.providers/01.provider.md index c73aa19b..c1eb434a 100644 --- a/content/sdk/10.js/00.ethers/05.api/20.v6/00.providers/01.provider.md +++ b/content/sdk/10.js/00.ethers/05.api/20.v6/00.providers/01.provider.md @@ -4,6 +4,9 @@ description: Provider objects for interacting with ZKsync. tags: ["zksync", "providers", "integration"] --- +Provider objects facilitate interaction with the ZKsync network, allowing users to manage transactions, estimate fees, +and retrieve network information. + ### `constructor` Creates a ZKsync Era `Provider` object. @@ -599,7 +602,7 @@ Returns true if passed bridge address is legacy and false if its shared bridge. async isL2BridgeLegacy(address: Address): Promise ``` -### Example +#### Example ```ts import { Provider, types } from "zksync-ethers"; diff --git a/content/sdk/10.js/00.ethers/05.api/20.v6/00.providers/02.browser-provider.md b/content/sdk/10.js/00.ethers/05.api/20.v6/00.providers/02.browser-provider.md index 6a4a7415..987946e7 100644 --- a/content/sdk/10.js/00.ethers/05.api/20.v6/00.providers/02.browser-provider.md +++ b/content/sdk/10.js/00.ethers/05.api/20.v6/00.providers/02.browser-provider.md @@ -48,6 +48,12 @@ and their examples. Returns the transaction receipt for the given transaction hash. +#### Inputs + +| Parameter | Type | Description | +| --------- | -------- | ----------------- | +| `txHash` | `string` | Transaction hash. | + ```ts async getTransactionReceipt(txHash: string): Promise ``` @@ -66,6 +72,12 @@ console.log(`Transaction receipt: ${utils.toJSON(await provider.getTransactionRe Returns the transaction for the given transaction hash. +#### Inputs + +| Parameter | Type | Description | +| --------- | -------- | ----------------- | +| `txHash` | `string` | Transaction hash. | + ```ts async getTransaction(txHash: string): Promise ``` @@ -90,6 +102,13 @@ await tx.waitFinalize(); Returns the block for the given block hash or block tag. +#### Inputs + +| Parameter | Type | Description | +| --------------------- | ---------- | ----------------------------------------------------------- | +| `blockHashOrBlockTag` | `BlockTag` | Block tag for getting the balance on. | +| `includeTxs?` | `boolean` | Whether to fetch transactions that are in block. | + ```ts async getBlock(blockHashOrBlockTag: BlockTag, includeTxs?: boolean): Promise ``` @@ -107,6 +126,12 @@ console.log(`Block: ${utils.toJSON(await provider.getBlock("latest", true))}`); Returns the logs that match the given filter. +#### Inputs + +| Parameter | Type | Description | +| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | +| `filter` | [`Filter`](https://docs.ethers.org/v6/api/providers/#Filter) or [`FilterByBlockHash`](https://docs.ethers.org/v6/api/providers/#FilterByBlockHash) | Filter query. | + ```ts async getLogs(filter: Filter | FilterByBlockHash): Promise ``` @@ -124,6 +149,14 @@ console.log(`Logs: ${utils.toJSON(await provider.getLogs({ fromBlock: 0, toBlock Returns the account balance for the specified account address, block tag, and token address. +#### Inputs + +| Parameter | Type | Description | +| --------------- | ---------- | ------------------------------------------------------------------------------------- | +| `address` | `Address` | Account address. | +| `blockTag?` | `BlockTag` | Block tag for getting the balance on. Latest `committed` block is default. | +| `tokenAddress?` | `Address` | Token address. ETH is default. | + ```ts async getBalance(address: Address, blockTag?: BlockTag, tokenAddress?: Address): Promise ``` @@ -144,6 +177,12 @@ console.log(`Token balance: ${await provider.getBalance(account, "latest", token Returns the L2 token address equivalent for a given L1 token address. +#### Inputs + +| Parameter | Type | Description | +| --------- | --------- | ------------------------------- | +| `token` | `Address` | The address of the token on L1. | + ```ts async l2TokenAddress(token: Address): Promise ``` @@ -161,6 +200,12 @@ console.log(`L2 token address: ${await provider.l2TokenAddress("0x5C221E77624690 Returns the L1 token address equivalent for a given L2 token address. +#### Inputs + +| Parameter | Type | Description | +| --------- | --------- | ------------------------------- | +| `token` | `Address` | The address of the token on L2. | + ```ts async l1TokenAddress(token: Address): Promise ``` @@ -178,6 +223,12 @@ console.log(`L1 token address: ${await provider.l1TokenAddress("0x3e7676937A7E96 Returns the protocol version. +#### Inputs + +| Parameter | Type | Description | +|-----------| -------- |---------------------------------| +| `id?` | `number` | Specific version ID (optional). | + ```ts async getProtocolVersion(id?: number): Promise ``` @@ -195,6 +246,12 @@ console.log(`Protocol version: ${await provider.getProtocolVersion()}`); Returns an estimate of the amount of gas required to submit a transaction from L1 to L2. +#### Inputs + +| Parameter | Type | Description | +| ------------- | -------------------------------------------------------- | ---------------------- | +| `transaction` | [`TransactionRequest`](/sdk/js/ethers/api/v6/types#transactionrequest) | Transaction request. | + ```ts async estimateGasL1(transaction: TransactionRequest): Promise ``` @@ -220,6 +277,12 @@ console.log(`L1 gas: ${BigInt(gasL1)}`); Returns an estimated fee for a requested transaction. +#### Inputs + +| Parameter | Type | Description | +| ------------- | ------------------------------------------------------------------------------------ | ---------------------- | +| `transaction` | [`TransactionRequest`](https://docs.ethers.org/v6/api/providers/#TransactionRequest) | Transaction request. | + ```ts async estimateFee(transaction: TransactionRequest): Promise ``` @@ -230,7 +293,9 @@ async estimateFee(transaction: TransactionRequest): Promise import { BrowserProvider, utils } from "zksync-ethers"; const provider = new BrowserProvider(window.ethereum); -const fee = await provider.estimateFee({ +const fee = await provider.estimateFee + +({ from: "0x36615Cf349d7F6344891B1e7CA7C72883F5dc049", to: "0xa61464658AfeAf65CccaaFD3a512b69A83B77618", value: `0x${BigInt(7_000_000_000).toString(16)}`, @@ -277,6 +342,13 @@ console.log(`Gas price: ${await provider.getGasPrice()}`); Returns the proof for a transaction's L2 to L1 log. +#### Inputs + +| Parameter | Type | Description | +| --------- | ----------- | ---------------------------------------------------------------- | +| `txHash` | `BytesLike` | Hash of the L2 transaction the L2 to L1 log was produced within. | +| `index?` | `number` | The index of the L2 to L1 log in the transaction. | + ```ts async getLogProof(txHash: BytesLike, index?: number): Promise ``` @@ -295,6 +367,12 @@ console.log(`Log ${utils.toJSON(await provider.getLogProof(tx, 0))}`); Returns the range of blocks contained within a batch given by batch number. +#### Inputs + +| Parameter | Type | Description | +| --------------- | -------- | ---------------- | +| `l1BatchNumber` | `number` | L1 batch number. | + ```ts async getL1BatchBlockRange(l1BatchNumber: number): Promise<[number, number] | null> ``` @@ -304,9 +382,7 @@ async getL1BatchBlockRange(l1BatchNumber: number): Promise<[number, number] | nu ```ts import { BrowserProvider, utils } from "zksync-ethers"; -const provider = - - new BrowserProvider(window.ethereum); +const provider = new BrowserProvider(window.ethereum); const l1BatchNumber = await provider.getL1BatchNumber(); console.log(`L1 batch block range: ${utils.toJSON(await provider.getL1BatchBlockRange(l1BatchNumber))}`); ``` @@ -383,6 +459,12 @@ console.log(`Is ETH based chain: ${await provider.isEthBasedChain()}`); Returns whether the `token` is the base token. +#### Inputs + +| Parameter | Type | Description | +| --------- | --------- | ------------------------- | +| `token` | `Address` | The address of the token. | + ```ts async isBaseToken(token: Address): Promise ``` @@ -442,6 +524,12 @@ console.log(`Default bridges: ${utils.toJSON(bridgeAddresses)}`); Returns all balances for confirmed tokens given by an account address. +#### Inputs + +| Parameter | Type | Description | +| --------- | --------- | ---------------- | +| `address` | `Address` | Account address. | + ```ts async getAllAccountBalances(address: Address): Promise ``` @@ -460,6 +548,13 @@ console.log(`All balances: ${utils.toJSON(balances)}`); Returns confirmed tokens bridged to ZKsync Era via the official bridge. +#### Inputs + +| Parameter | Type | Description | +|-----------| --------- |----------------------------------------------------| +| `start` | `Address` | The token id from which to start. Default 0. | +| `limit` | `Address` | The maximum number of tokens to list. Default 255. | + ```ts async getConfirmedTokens(start = 0, limit = 255): Promise ``` @@ -513,6 +608,12 @@ console.log(`L1 batch number: ${await provider.getL1BatchNumber()}`); Returns data pertaining to a given batch. +#### Inputs + +| Parameter | Type | Description | +| --------- | -------- | ---------------- | +| `number` | `number` | L1 batch number. | + ```ts async getL1BatchDetails(number: number): Promise ``` @@ -533,6 +634,12 @@ console.log(`L1 batch details: ${utils.toJSON(await provider.getL1BatchDetails(l Returns additional ZKsync-specific information about the L2 block. +#### Inputs + +| Parameter | Type | Description | +| --------- | -------- | ------------- | +| `number` | `number` | Block number. | + ```ts async getBlockDetails(number: number): Promise ``` @@ -540,7 +647,9 @@ async getBlockDetails(number: number): Promise #### Example ```ts -import { BrowserProvider, utils } from "zksync-ethers"; +import { BrowserProvider, utils } from "zksync + +-ethers"; const provider = new BrowserProvider(window.ethereum); console.log(`Block details: ${utils.toJSON(await provider.getBlockDetails(90_000))}`); @@ -550,6 +659,12 @@ console.log(`Block details: ${utils.toJSON(await provider.getBlockDetails(90_000 Returns data from a specific transaction given by the transaction hash. +#### Inputs + +| Parameter | Type | Description | +| --------- | ----------- | ----------------- | +| `txHash` | `BytesLike` | Transaction hash. | + ```ts async getTransactionDetails(txHash: BytesLike): Promise ``` @@ -569,6 +684,12 @@ console.log(`Transaction details: ${utils.toJSON(await provider.getTransactionDe Returns bytecode of a contract given by its hash. +#### Inputs + +| Parameter | Type | Description | +| -------------- | ----------- | -------------- | +| `bytecodeHash` | `BytesLike` | Bytecode hash. | + ```ts async getBytecodeByHash(bytecodeHash: BytesLike): Promise ``` @@ -592,6 +713,12 @@ console.log(`Bytecode: ${await provider.getBytecodeByHash(testnetPaymasterByteco Returns data of transactions in a block. +#### Inputs + +| Parameter | Type | Description | +| --------- | -------- | ------------- | +| `number` | `number` | Block number. | + ```ts async getRawBlockTransactions(number: number): Promise ``` @@ -609,6 +736,14 @@ console.log(`Raw block transactions: ${utils.toJSON(await provider.getRawBlockTr Returns Merkle proofs for one or more storage values at the specified account. +#### Inputs + +| Parameter | Type | Description | +| --------------- | ---------- | ----------------------------------------------------------------------------------------------- | +| `address` | `Address` | The account to fetch storage values and proofs for. | +| `keys` | `string[]` | Vector of storage keys in the account. | +| `l1BatchNumber` | `number` | Number of the L1 batch specifying the point in time at which the requested values are returned. | + ```ts async getProof(address: Address, keys: string[], l1BatchNumber: number): Promise ``` @@ -635,9 +770,7 @@ const slotPadded = ethers.zeroPadValue(ethers.toBeHex(0), 32); // Concatenate the padded address and slot number. const concatenated = addressPadded + slotPadded.slice(2); // slice to remove '0x' from the slotPadded - - -// Hash the concatenated string to get the storage key. +// Hash the concatenated string using Keccak-256. const storageKey = ethers.keccak256(concatenated); const l1BatchNumber = await provider.getL1BatchNumber(); @@ -649,6 +782,12 @@ console.log(`Proof: ${utils.toJSON(proof)}`); Returns a signer object for the provider. +#### Inputs + +| Parameter | Type | Description | +| --------- | --------- | ---------------- | +| `address?` | `Address` | Account address. | + ```ts async getSigner(address?: Address): Promise ``` @@ -665,9 +804,9 @@ const signer = await provider.getSigner(); console.log(`Signer address: ${await signer.getAddress()}`); ``` -### Appendix +## Appendix -#### toJSON +### toJSON ```ts function toJSON(object: any): string { diff --git a/content/sdk/10.js/00.ethers/05.api/20.v6/01.accounts/01.wallet.md b/content/sdk/10.js/00.ethers/05.api/20.v6/01.accounts/01.wallet.md index 575684a1..f7883bca 100644 --- a/content/sdk/10.js/00.ethers/05.api/20.v6/01.accounts/01.wallet.md +++ b/content/sdk/10.js/00.ethers/05.api/20.v6/01.accounts/01.wallet.md @@ -4,6 +4,8 @@ description: Wallet integration, creation, and management in ZKsync. tags: ["zksync", "wallet", "integration", "creation", "management"] --- +The Wallet module provides functionalities for integrating, creating, and managing wallets within the ZKsync ecosystem. + ### `constructor` #### Inputs diff --git a/content/sdk/10.js/00.ethers/05.api/20.v6/01.accounts/04.eip712signer.md b/content/sdk/10.js/00.ethers/05.api/20.v6/01.accounts/04.eip712signer.md index 8ea0a59e..862747d6 100644 --- a/content/sdk/10.js/00.ethers/05.api/20.v6/01.accounts/04.eip712signer.md +++ b/content/sdk/10.js/00.ethers/05.api/20.v6/01.accounts/04.eip712signer.md @@ -4,7 +4,8 @@ description: How to integrate EIP712Signer with ZKsync and ethers.js tags: ["zksync", "ethers.js", "blockchain", "EIP712", "smart contracts"] --- -Provides support for an EIP712 transaction. The methods of this class are mostly used internally. + +This class provides support for an EIP712 transaction. The methods of this class are mostly used internally. ### `getSignInput` diff --git a/content/sdk/10.js/00.ethers/05.api/20.v6/04.utilities/02.smart-account-utils.md b/content/sdk/10.js/00.ethers/05.api/20.v6/04.utilities/02.smart-account-utils.md index 0148e849..3fba22a3 100644 --- a/content/sdk/10.js/00.ethers/05.api/20.v6/04.utilities/02.smart-account-utils.md +++ b/content/sdk/10.js/00.ethers/05.api/20.v6/04.utilities/02.smart-account-utils.md @@ -4,6 +4,8 @@ description: Utilities for signing payloads and populating transactions with ECD tags: ["zksync", "smart accounts", "ecdsa", "blockchain", "cryptocurrency"] --- +This module provides utilities for signing transactions with ECDSA private keys in the ZKsync ecosystem. + ## Functions ### `signPayloadWithECDSA` diff --git a/content/sdk/10.js/00.ethers/05.api/20.v6/05.types.md b/content/sdk/10.js/00.ethers/05.api/20.v6/05.types.md index 6b2558d2..401d4c0f 100644 --- a/content/sdk/10.js/00.ethers/05.api/20.v6/05.types.md +++ b/content/sdk/10.js/00.ethers/05.api/20.v6/05.types.md @@ -4,6 +4,9 @@ description: Definitions and interfaces used in ZKsync Era. tags: ["zksync", "types", "interfaces", "ethereum", "blockchain"] --- +These types and interfaces are essential for developers working with the ZKsync blockchain, as they define the +structures and enumerations for different components of the system. + ## `AccountAbstractionVersion` Enumerated list of account abstraction versions.