Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions src/pages/build/onchain-clients.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ To connect to Ink by instantiating a new `ethers.js` `JsonRpcProvider` object wi

const rpcUrl = 'https://rpc-gel-sepolia.inkonchain.com';
const provider = new ethers.JsonRpcProvider(rpcUrl, 763373);

async function main() {
const blockNumber = await provider.getBlockNumber();
console.log(blockNumber);
}

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

3. **Using the Provider**: You can now use the `provider` to interact with Ink's testnet. For example, you can fetch the current block number or interact with smart contracts deployed on the testnet.

```javascript
// previous code
const blockNumber = await provider.getBlockNumber();
console.log(blockNumber);
```

### Example: Fetching the Current Block Number

The following code snippet demonstrates how to fetch and print the current block number from Ink's testnet:
Expand Down Expand Up @@ -64,12 +65,13 @@ Viem documentation: [https://viem.sh/docs/introduction](https://viem.sh/docs/int
chain: inkSepolia,
transport: http(),
})

async function main() {
const blockNumber = await client.getBlockNumber();
console.log(blockNumber);
}

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

3. **Consuming Actions**: You can now interact with Ink's chain! Here we are getting the current block number.

```javascript
// previous code
const blockNumber = await client.getBlockNumber();
console.log(blockNumber);
```