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

Commit

Permalink
fix(js-sdk): document Provider.getBytecodeByHash and `Provider.getR…
Browse files Browse the repository at this point in the history
…awBlockTransactions` (#800)

Co-authored-by: Dennis <[email protected]>
  • Loading branch information
danijelTxFusion and idea404 authored Dec 4, 2023
1 parent cf2a9ed commit f76b8ad
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/api/js/zksync2-js/examples/withdraw.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider);
const WITHDRAW_TX = process.env.WITHDRAW_TX;

async function main() {
if (!wallet.isWithdrawalFinalized(WITHDRAW_TX)) {
if (!(await wallet.isWithdrawalFinalized(WITHDRAW_TX))) {
const finalizeWithdrawTx = await wallet.finalizeWithdrawal(WITHDRAW_TX);
const receipt = await finalizeWithdrawTx.wait();
console.log(`Tx: ${receipt.hash}`);
Expand Down
52 changes: 52 additions & 0 deletions docs/api/js/zksync2-js/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,31 @@ const provider = Provider.getDefaultProvider(types.Network.Goerli);
console.log(`Block details: ${toJSON(await provider.getBlockDetails(90_000))}`);
```

### `getBytecodeByHash`

Returns bytecode of a transaction given by its hash.

Calls the [`zks_getBytecodeByHash`](../../api.md#zks-getbytecodebyhash) JSON-RPC method.

#### Inputs

| Parameter | Type | Description |
| -------------- | ----------- | -------------- |
| `bytecodeHash` | `BytesLike` | Bytecode hash. |

```ts
async getBytecodeByHash(bytecodeHash: BytesLike): Promise<Uint8Array>
```

#### Example

```ts
import { Provider, types } from "zksync2-js";

const provider = Provider.getDefaultProvider(types.Network.Goerli);
console.log(`Bytecode: ${await provider.getBytecodeByHash("0x0f9acdb01827403765458b4685de6d9007580d15")}`);
```

### `getConfirmedTokens`

Returns [address, symbol, name, and decimal] information of all tokens within a range of ids given by parameters `from` and `limit`.
Expand Down Expand Up @@ -799,6 +824,33 @@ if (l1TxResponse) {
}
```

### `getRawBlockTransactions`

Returns data of transactions in a block.

Calls the [`zks_getRawBlockTransactions`](../../api.md#zks-getrawblocktransactions) JSON-RPC method.

#### Inputs

| Parameter | Type | Description |
| --------- | -------- | ------------- |
| `number` | `number` | Block number. |

```ts
async getRawBlockTransactions(number: number): Promise<RawBlockTransaction[]>
```

#### Example

Helper function: [toJSON](#tojson).

```ts
import { Provider, types } from "zksync2-js";

const provider = Provider.getDefaultProvider(types.Network.Goerli);
console.log(`Raw block transactions: ${toJSON(await provider.getRawBlockTransactions(90_000))}`);
```

### `getTestnetPaymasterAddress`

Returns the [testnet paymaster](../../../reference/concepts/account-abstraction.md#paymasters) address if available, or null.
Expand Down

0 comments on commit f76b8ad

Please sign in to comment.