Skip to content

Commit

Permalink
docs: update web3js guide scripts (#51)
Browse files Browse the repository at this point in the history
# Description

- Prepping for zksyncdevs threads, I saw there are misspells on scripts,
not sure if someone was checking the scripts.

---------

Co-authored-by: Sabrina <sf@matterlabs.dev>
  • Loading branch information
AlbionaHoti and itsacoyote authored Aug 28, 2024
1 parent 99730e3 commit 65d1407
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions content/tutorials/guide-web3js/10.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ and [register the plugin](https://docs.web3js.org/guides/web3_plugin_guide/plugi

```javascript
import { Web3 } from "web3";
import { ZkSyncPlugin } from "web3-plugin-zksync";
import { ZKsyncPlugin } from "web3-plugin-zksync";

const zkSyncRpcUrl: string = "https://sepolia.era.zksync.dev";
const zksyncRpcUrl: string = "https://sepolia.era.zksync.dev";

console.log(`📞 Connecting to ZKsync Era [${zkSyncRpcUrl}]`);
const web3: Web3 = new Web3(zkSyncRpcUrl);
web3.registerPlugin(new ZkSyncPlugin());
console.log(`📞 Connecting to ZKsync Era [${zksyncRpcUrl}]`);
const web3: Web3 = new Web3(zksyncRpcUrl);
web3.registerPlugin(new ZKsyncPlugin(zksyncRpcUrl));
```

::callout{icon="i-heroicons-exclamation-circle"}
Expand All @@ -52,8 +52,13 @@ Use the Web3.js `eth` package to fetch data from the ZKsync [Ethereum JSON-RPC A
#### Fetch the Latest Block Number

```javascript
const blockNumber = await web3.eth.getBlockNumber();
console.log(`Current block number: ${blockNumber}`);

async function main() {
const blockNumber = await web3.eth.getBlockNumber();
console.log(`Current block number: ${blockNumber}`);
}

main().catch(console.error);
```

### ZKsync L2-Specific JSON-RPC API
Expand All @@ -65,8 +70,12 @@ from the `zks_` namespace of the [JSON-RPC API](https://docs.zksync.io/build/api

<!-- /*spellchecker: disable*/ -->
```javascript
const mainContract = await web3.zkSync.rpc.getMainContract();
console.log(`Main contract: ${mainContract}`);
async function main() {
const mainContract = await web3.ZKsync.rpc.getMainContract();
console.log(`Main contract: ${mainContract}`);
}

main().catch(console.error);
```
<!-- /*spellchecker: enable*/ -->

Expand Down

0 comments on commit 65d1407

Please sign in to comment.