-
-
Notifications
You must be signed in to change notification settings - Fork 766
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: zks namespace * feat: add new zks json-rpc methods * chore: applied proper formating * feat: update docs * feat: add default bridges method * feat: add more methods and improve docs and tests * chore: update imports * chore: update actions and tests * fix: update estimateFee for eip712 transaction * chore: fix types and logProof mock data * fix: resolve return types, update test cases and actions * chore: apply lint * fix: remove unnessecary parameters when formating * fix: export missing public l2 actions * fix: update imports * feat: add estimateGasL1ToL2 action * fix: add missing zksync test clients * fix: types * chore: changeset --------- Co-authored-by: moxey.eth <jakemoxey@gmail.com>
- Loading branch information
1 parent
66f3eea
commit c2c0791
Showing
66 changed files
with
3,283 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"viem": minor | ||
--- | ||
|
||
**zkSync Extension:** Added support for `zks_` namespace + actions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
VITE_ACCOUNT_PRIVATE_KEY= | ||
VITE_ANVIL_FORK_URL= | ||
VITE_ANVIL_FORK_URL_OPTIMISM= | ||
VITE_ANVIL_BLOCK_TIME=1 | ||
VITE_ANVIL_BLOCK_NUMBER=16280770 | ||
VITE_ANVIL_BLOCK_NUMBER_OPTIMISM=112157024 | ||
VITE_ANVIL_PORT=8545 | ||
VITE_ANVIL_PORT_OPTIMISM=8645 | ||
VITE_BATCH_JSON_RPC=false | ||
VITE_BATCH_MULTICALL=false | ||
VITE_NETWORK_TRANSPORT_MODE=http | ||
VITE_NETWORK_TRANSPORT_MODE=http | ||
VITE_RPC_URL_OPTIMISM= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
--- | ||
description: Returns an estimated Fee for requested transaction. | ||
--- | ||
|
||
# estimateFee | ||
|
||
Returns an estimated Fee for requested transaction. | ||
|
||
## Usage | ||
|
||
:::code-group | ||
|
||
```ts [example.ts] | ||
import { client } from './config' | ||
|
||
const fee = await client.estimateFee({ | ||
account: '0x636A122e48079f750d44d13E5b39804227E1467e', | ||
to: "0xa61464658AfeAf65CccaaFD3a512b69A83B77618", | ||
value: 0n | ||
}); | ||
``` | ||
|
||
```ts [config.ts] | ||
import { createPublicClient, http } from 'viem' | ||
import { zkSync } from 'viem/chains' | ||
import { publicActionsL2 } from 'viem/zksync' | ||
|
||
export const client = createPublicClient({ | ||
chain: zkSync, | ||
transport: http(), | ||
}).extend(publicActionsL2()) | ||
``` | ||
::: | ||
|
||
## Returns | ||
|
||
`Fee` | ||
|
||
The fee values. | ||
|
||
## Parameters | ||
|
||
### account | ||
|
||
- **Type:** `Account | Address` | ||
|
||
The Account to send the transaction from. | ||
|
||
Accepts a [JSON-RPC Account](/docs/clients/wallet#json-rpc-accounts) or [Local Account (Private Key, etc)](/docs/clients/wallet#local-accounts-private-key-mnemonic-etc). | ||
|
||
```ts | ||
const fee = await walletClient.estimateFee({ | ||
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', // [!code focus] | ||
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', | ||
value: 1000000000000000000n | ||
}) | ||
``` | ||
|
||
### to | ||
|
||
- **Type:** `0x${string}` | ||
|
||
The transaction recipient or contract address. | ||
|
||
```ts | ||
const fee = await walletClient.estimateFee({ | ||
account, | ||
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', // [!code focus] | ||
value: 1000000000000000000n, | ||
nonce: 69 | ||
}) | ||
``` | ||
|
||
### data (optional) | ||
|
||
- **Type:** `0x${string}` | ||
|
||
A contract hashed method call with encoded args. | ||
|
||
```ts | ||
const fee = await walletClient.estimateFee({ | ||
data: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', // [!code focus] | ||
account, | ||
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', | ||
value: 1000000000000000000n | ||
}) | ||
``` | ||
|
||
### gasPrice (optional) | ||
|
||
- **Type:** `bigint` | ||
|
||
The price (in wei) to pay per gas. Only applies to [Legacy Transactions](/docs/glossary/terms#legacy-transaction). | ||
|
||
```ts | ||
const fee = await walletClient.estimateFee({ | ||
account, | ||
gasPrice: parseGwei('20'), // [!code focus] | ||
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', | ||
value: 1000000000000000000n | ||
}) | ||
``` | ||
|
||
### nonce (optional) | ||
|
||
- **Type:** `number` | ||
|
||
Unique number identifying this transaction. | ||
|
||
```ts | ||
const fee = await walletClient.estimateFee({ | ||
account, | ||
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', | ||
value: 1000000000000000000n, | ||
nonce: 69 // [!code focus] | ||
}) | ||
``` | ||
|
||
### value (optional) | ||
|
||
- **Type:** `bigint` | ||
|
||
Value in wei sent with this transaction. | ||
|
||
```ts | ||
const fee = await walletClient.estimateFee({ | ||
account, | ||
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', | ||
value: parseEther('1'), // [!code focus] | ||
nonce: 69 | ||
}) | ||
``` | ||
|
||
### gasPerPubdata (optional) | ||
|
||
- **Type:** `bigint` | ||
|
||
The amount of gas for publishing one byte of data on Ethereum. | ||
|
||
```ts | ||
const fee = await walletClient.estimateFee({ | ||
account, | ||
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', | ||
gasPerPubdata: 50000, // [!code focus] | ||
nonce: 69, | ||
value: 1000000000000000000n | ||
}) | ||
``` | ||
|
||
### factoryDeps (optional) | ||
|
||
- **Type:** `[0x${string}]` | ||
|
||
Contains bytecode of the deployed contract. | ||
|
||
```ts | ||
const fee = await walletClient.estimateFee({ | ||
account, | ||
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', | ||
factoryDeps: ['0xcde...'], // [!code focus] | ||
nonce: 69, | ||
value: 1000000000000000000n | ||
}) | ||
``` | ||
|
||
### paymaster (optional) | ||
|
||
- **Type:** `Account | Address` | ||
|
||
Address of the paymaster account that will pay the fees. The `paymasterInput` field is required with this one. | ||
|
||
```ts | ||
const fee = await walletClient.estimateFee({ | ||
account, | ||
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', | ||
paymaster: '0x4B5DF730c2e6b28E17013A1485E5d9BC41Efe021', // [!code focus] | ||
paymasterInput: '0x8c5a...' // [!code focus] | ||
nonce: 69, | ||
value: 1000000000000000000n | ||
}) | ||
``` | ||
|
||
### paymasterInput (optional) | ||
|
||
- **Type:** `0x${string}` | ||
|
||
Input data to the paymaster. The `paymaster` field is required with this one. | ||
|
||
```ts | ||
const fee = await walletClient.estimateFee({ | ||
account, | ||
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', | ||
paymaster: '0x4B5DF730c2e6b28E17013A1485E5d9BC41Efe021', // [!code focus] | ||
paymasterInput: '0x8c5a...' // [!code focus] | ||
nonce: 69, | ||
value: 1000000000000000000n | ||
}) | ||
``` |
Oops, something went wrong.